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

Problem of the day

You are given two arrays/lists * ‘A’* and

You must return ‘K’ distinct maximum and valid sum combinations from all the possible sum combinations of the arrays/lists ‘A’ and ‘B’.

Sum combination adds one element from array ‘A’ and another from array ‘B’.

```
A : [1, 3]
B : [4, 2]
K: 2
The possible sum combinations can be 5(3 + 2), 7(3 + 4), 3(1 + 2), 5(1 + 4).
The 2 maximum sum combinations are 7 and 5.
```

Detailed explanation

```
3 2
1 3 5
6 4 2
```

```
11 9
```

```
For the given arrays/lists, all the possible sum combinations are:
7(1 + 6), 5(1 + 4), 3(1 + 2), 9(3 + 6), 7(3 + 4), 5(3 + 2), 11(6 + 5), 9(5 + 4), 7(5 + 2).
The two maximum sum combinations from the above combinations are 11 and 9.
```

```
2 1
1 1
1 1
```

```
2
```

```
For the given arrays/lists, two possible sum combinations are 2(1 + 1), and 2(1 + 1).
```

```
1 <= N <= 100
1 <= K <= N
-10^5 <= A[i], B[i] <= 10^5
'A[i]' and 'B[i]' denote the ith element in the given arrays/lists.
Time limit: 1 sec
```