58. Pair With a Given Sum
Challenge1000 ms256 MBSolved by 0%
You are given an array and a target value k.
Print Yes if some two different positions in the array hold values that add up to
k, or No if no such pair exists.
The same position cannot be used twice, but two positions holding the same value are fine.
Constraints - `1 ≤ n ≤ 200000` - `-1000000 ≤ a[i] ≤ 1000000` - `-2000000 ≤ k ≤ 2000000`
Input
The first line contains an integer n.
The second line contains n space-separated integers.
The third line contains an integer k.
Output
Print exactly one word: Yes or No.
Input5
2 7 11 15 3
9
OutputYes
Notehas the pair 2 and 7
Input4
1 2 3 4
100
OutputNo
Notehas no pair reaching the target
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution