@BiGYaN the answer here is correct, but there isnβt enough humor on the trip to get this result (even from the links provided), so I decided to add this -
First, the OP should not take an analogy with the set, because by definition the set does not take into account the order and, in addition, contains unique elements.
If we take the same example in which n = 6 or [1,2,3,4,5,6], now we need to get a sequence of length 3 such that -
pattern = d1 <= d2 <= d3 (d for the digit).
We need sequences such as: {[1,1,1], [1,1,2], ...., [2,2,3], [2,2,4], ...}. Now for such sequences, scan the template on the left and try to reason if we want to increase the numbers or not.
For example: start from the left edge of d1 and reason, if you want to increase d1 right here or not, if you donβt decide, d1 will be β1β, and now go ahead and ask the same question immediately before d2, if you decide not to go up again , d2 is again "1".
You can select up to 5 times at any time, because the range is [1-6], and d1 should be 6, at least if you decide to increase it 5 times to get [6,6,6].
So, the problem is to choose a suitable place for 5 ups among
[up up up up up d1 d2 d3]
It can be [up d1 up up up d2 d3], which gives [2,6,6], or [d1 up up d2 up d3 up], which gives [1,4,5], or any combination like this.
So, in fact, the answer is C (5 up + 3 d's, 5 ups) or, in general
C(n-1 up + k digits, n-1 up's) or C(n-1+k, n-1)
where, k things should be selected in sorted order from n things.