Given an array arr of positive integers and another number target. Determine whether two elements exist in arr whose sum is exactly target or not. Return true if two elements exist in the arr else return false.
Example 1
Input: arr[] = [1, 4, 9, 6, 10, 8], target =16
Output: true
Explanation: arr[3] + arr[4] = 6 + 10 = 16
Example 2
Input: arr[] = [1, 2, 4, 3, 6], target = 11
Output: false
Explanation: None of the pair makes a sum of 11
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
16 1 4 9 6 10 8
true
3 1 2
true