Login

Striver SDE Sheet Problems

Problem title

Difficulty

Avg time to solve

Longest Consecutive Sequence

Moderate

40 mins

Valid Parentheses

Easy

10 mins

N Queens

Hard

55 mins

Rat In a Maze All Paths

Moderate

40 mins

Return Subsets Sum to K

Moderate

40 mins

Sudoku?

Moderate

40 mins

LRU Cache Implementation

Moderate

25 mins

Print Permutations - String

Easy

30 mins

Implement Stack With Linked List

Moderate

30 mins

Ways To Make Coin Change

Moderate

20 mins

Problem

Submissions

9

Avg. time to solve

40 min

Success Rate

75%

Problem Statement

```
The order of subsets is not important.
The order of elements in a particular subset should be in increasing order of the index.
```

```
The first line of input contains an integer 'N', which denotes the size of the array.
The second line contains 'N' single-space separated integers representing the elements of the array.
The third line contains a single integer 'K', which denotes the integer to which the subsets should sum to.
```

```
For each test case, print single-space separated integers of a subset of 'ARR' having sum = 'K'.
The output of each test case will be printed in a separate line.
```

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

```
1 <= 'N' <= 16
- (10 ^ 6) <= ARR[i] <= (10 ^ 6)
- 16 * (10 ^ 6) <= 'K' <= 16 * (10 ^ 6)
Where ‘ARR[i]’ denotes the value for ‘ith’ element of the array ‘ARR’ and 'K' is the given sum.
Time Limit: 1 sec.
```

```
3
2 4 6
6
```

```
2 4
6
```

```
For the array'ARR' = {2, 4, 6}, we can have subsets {}, {2}, {4}, {6}, {2, 4}, {2, 6}, {4, 6}, {2, 4, 6}. Out of these 8 subsets, {2, 4} and {6} sum to the given 'K' i.e. 6.
```

```
6
5 -1 8 2 7 0
7
```

```
-1 8
-1 8 0
5 2
5 2 0
7
7 0
```

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