Created
December 1, 2019 21:13
-
-
Save kwojcicki/4e44f0a2bfd31753b07a4b031bb8b1a5 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