Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

Given a number 'N', you need to find all possible unique ways to represent this number as the sum of positive integers.

```
1. By unique it is meant that no other composition can be expressed as a permutation of the generated composition. For eg. [1, 2, 1] and [1, 1, 2] are not unique.
2. You need to print all combinations in non-decreasing order for eg. [1, 2, 1] or [1, 1, 2] will be printed as [1, 1, 2], however, the order of printing all the sequences can be random.
```

Detailed explanation

```
1 <= N <= 50
Time Limit: 1sec
```

```
4
```

```
4
1 1 1 1
1 1 2
2 2
1 3
```

```
Here notice that all combinations are sorted in non-decreasing order and [1, 1, 2] and [1, 2, 1] are the same and printed as [1, 1, 2].
Note: 1 1 1 1
2 2
4
1 3
1 1 2 is also a valid output as the order of different sequences doesn’t matter.
```

```
1
```

```
1
```