Open
Description
Given a sum of positive integers S
and a their number n
, find the number of distinct arrays under these conditions:
-
In each array, there are
n
elements whose sum is equal toS
. -
In each array, each element should be greater than or equal to the element on its left.
-
The elements formed in each array are distinct
-
E.g. 1.:
- Inputs: S = 8 n = 4
- Output: 5
- Explanation: [1,1,1,5], [1,1,2,4], [1,1,3,3], [1,2,2,3], [2,2,2,2]
- Each array has 4 (
n
) elements a sum of 8 (S
) with each element on the left<=
element on the right. There are 5 possible distinct options.