Created
December 1, 2019 22:39
-
-
Save kwojcicki/6dd02f88a37147be90dcf3ef5871d2d1 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