| Topic | Difficulty | Companies |
|---|---|---|
| Hash Table | MEDIUM | Google Facebook Amazon |
Given an array arr of n integers and a number sum, write a program to check whether there is a pair of elements in the array that sums to exactly sum.
Problem Note
Example 1
Input: arr[] = [-5, 1, -40, 20, 6, 8, 7 ], sum = 15
Output: 1
Explanation: (7, 8) and (-5, 20) are the pairs with sum 15.
Example 2
Input: arr[] = [-5, 4, -2, 16, 8, 9], sum = 15
Output: 0
Explanation: There is no pair of elements whose sum is equal to 15.