Problem title
Difficulty
Avg time to solve

Sum of Two Elements Equals the Third.
Easy
10 mins
Number of balanced binary trees
Easy
10 mins
Search a 2D Matrix II
Easy
15 mins
Goku and Dragon Balls
Moderate
35 mins
Word Break
Moderate
15 mins
Remove Duplicates from Sorted Array
Easy
15 mins
Sub Matrices With Sum Zero
Moderate
15 mins
Combination Sum II
Moderate
30 mins
Minimum Swaps
Moderate
10 mins
Shuffle Two Strings
Hard
50 mins
11

# Number Of Pairs With Given Sum

Difficulty: MEDIUM
Contributed By
Anish De |Level 1
Avg. time to solve
39 min
Success Rate
60%

Problem Statement

#### You have been given an integer array/list(arr) and a number 'Sum'. Find and return the total number of pairs in the array/list which when added, results equal to the 'Sum'.

##### Note:
Given array/list can contain duplicate elements.

(arr[i],arr[j]) and (arr[j],arr[i]) are considered same.
##### Input format :
The first line contains 2 space-separated integers N and Sum.

The next line contains N space-separated integers representing array elements.
##### Output format :
Print the total number of pairs present in the array/list.
##### Constraints :
1 <= N <= 10^5
-10^4 <= Sum <= 10^4
-10^4 <=  arr[ i ] <= 10^4

Time Limit: 1 sec
##### Sample Input 1:
9 12
1 3 6 2 5 4 3 2 4
0
##### Explanation For Sample Input 1:
Since there doesn't exist any pair with a sum equal to 12, so we print 0.
6 10
2 8 10 5 -2 5
2
Console