A cloth manufaturing company wants to make X different pattern t-shirts .They uses colours , colours which can put on the back of T-shirt.Now you have colour array of length n which tells the colour number ,here each colour is unique. You can make colour pattern using only limited number of colours at a time which is represented by k. Find X and generate all patterns .
EDIT :I forgot to mention , Each number you can use in particular pattern upto 4 times.
for example if n=[1,2,3] and k=5 then you can't build k=[1,1,1,1,1] but can build [1,1,1,1,3]
Note : each colour can be repeated itself in pattern any number of times
Contraints
1<n<=10^5
1=<k<n<=10^4
Input : n=[1,2,3], k=2
Output : X = 6
patterns = [1,2],[1,3],[2,2],[2,3],[3,3],[1,1]
Note : here you can't use [2,1] since it is same as [1,2]
Next level
After solving this interviewer edited question and asked me to count X and generate pattern for
unique sums. include all patterns with different sum
for example
if n=[1,2,3, 4] , k=3
then I can count [2,2,2] , [3,2,1] and other arrays having sum 6 as 1 only and include lexicographically
smallest pattern among the similar sum arrays .