All Problems

Problem title

Difficulty

Avg time to solve

LCA of three Nodes

Easy

20 mins

Sum Of Infinite Array

Moderate

35 mins

Pair Sum

Easy

15 mins

Sum or Product

Easy

15 mins

Reverse The Array

Easy

15 mins

Flower Shop

Easy

--

Find Duplicate in Array

Easy

15 mins

Sort 0 1 2

Easy

22 mins

Two Sum

Easy

10 mins

Beautiful String

Easy

18 mins

Problem

Submissions

1126

Avg. time to solve

15 min

Success Rate

90%

Problem Statement

```
Each pair should be sorted i.e the first value should be less than or equals to the second value.
Return the list of pairs sorted in non-decreasing order of their first value. In case if two pairs have the same first value, the pair with a smaller second value should come first.
```

```
The first line of input contains two space-separated integers 'N' and 'S', denoting the size of the input array and the value of 'S'.
The second and last line of input contains 'N' space-separated integers, denoting the elements of the input array: ARR[i] where 0 <= i < 'N'.
```

```
Print 'C' lines, each line contains one pair i.e two space-separated integers, where 'C' denotes the count of pairs having sum equals to given value 'S'.
```

```
You are not required to print the output, it has already been taken care of. Just implement the function.
```

```
1 <= N <= 10^3
-10^5 <= ARR[i] <= 10^5
-2 * 10^5 <= S <= 2 * 10^5
Time Limit: 1 sec
```

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

```
1 4
2 3
```

```
Here, 1 + 4 = 5
2 + 3 = 5
Hence the output will be, (1,4) , (2,3).
```

```
5 0
2 -3 3 3 -2
```

```
-3 3
-3 3
-2 2
```

Java (SE 1.8)

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 Theme

Solution submission not allowed

Save Code

Reset Code