Created
December 1, 2019 23:09
-
-
Save kwojcicki/cb5beffbaa9658b316043db39de90928 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