Login

Top Apple Coding Interview Questions

Problem title

Difficulty

Avg time to solve

Break Number

Moderate

35 mins

Longest Consecutive Sequence

Moderate

40 mins

Word Break-1

Moderate

36 mins

Implement Trie

Hard

41 mins

Find Number Of Islands

Moderate

34 mins

Excel Column Number

Easy

23 mins

Intersection of Linked List

Easy

25 mins

Search In Rotated Sorted Array

Moderate

30 mins

Rotting Oranges

Moderate

20 mins

Reverse Words In A String

Easy

10 mins

Problem

Submissions

1

Avg. time to solve

35 min

Success Rate

70%

Problem Statement

```
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.
```

```
The first and the only line of the input contains an integer 'N' representing the given number.
```

```
Each line of the output contains one unique sequence which sums up to 'N'.
There will be 'K' lines of output containing one unique sequence on each line in non-decreasing order which sums up to 'N'. 'K' is the total number of unique sequences.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
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
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code