New update is available. Click here to update.

Posted: 18 Feb, 2021

Difficulty: Easy

```
1. Pair (x,y) and Pair(y,x) are considered as the same pair.
2. If there exists no such pair with sum equals to 'TARGET', then return -1.
```

```
Let ‘ARR’ = [1 2 3] and ‘TARGET’ = 4. Then, there exists only one pair in ‘ARR’ with a sum of 4 which is (1, 3). (1, 3) and (3, 1) are counted as only one pair.
```

```
The first line of input contains an integer ‘T’ which denotes the number of test cases.
The first line of each test case contains two single space-separated integers ‘N’ and ‘TARGET’ representing the number of elements in the array/list ‘ARR’ and the required pair-sum respectively.
The next line of each test case contains ‘N’ single space-separated integers denoting the elements of ‘ARR’.
```

```
For each test case, return the numbers of pairs in ‘ARR’ whose sum is equal to ‘TARGET’.
```

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

```
1 <= ‘T’ <= 100
2 <= ‘N’ <= 5000
1 <= ‘ARR[i]’, ‘TARGET’ <= 10^5
Where ARR[i]’ represents the elements of array/list ‘ARR’.
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Best time to buy and sell stock II

Posted: 5 Sep, 2022

Difficulty: Moderate

Ninja And The Class Room

Posted: 19 Sep, 2022

Difficulty: Easy

Array Rotation

Posted: 21 Oct, 2022

Difficulty: Easy

Find The Single Element

Posted: 30 Oct, 2022

Difficulty: Easy

Three Sum

Posted: 24 Nov, 2022

Difficulty: Moderate

Categories:

Popular Courses: