Created
December 1, 2019 21:13
-
-
Save kwojcicki/7a3678bd707e84aa14c06768d10225fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pair findPairGivingSumUsingMap(int[] numbers, int k){ | |
Set<Integer> seen = new HashSet<Integer>(); | |
for(int i = 0; i < numbers.length; i++){ | |
if(seen.contains(k - numbers[i])){ | |
return new Pair(numbers[i], k - numbers[i]); | |
} | |
seen.add(numbers[i]); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment