Created
December 1, 2019 22:41
-
-
Save kwojcicki/218ce02280d4ab889489cf46c02e52f6 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