(int[] nums, int target)
| 1 | /** Problem: https://leetcode.com/explore/interview/card/google/59/array-and-strings/3049/ */ |
| 2 | class Solution { |
| 3 | public int[] twoSum(int[] nums, int target) { |
| 4 | Map<Integer, Integer> map = new HashMap<Integer, Integer>(); |
| 5 | |
| 6 | for (int i = 0; i < nums.length; i++) { |
| 7 | int complement = target - nums[i]; |
| 8 | |
| 9 | if (map.containsKey(complement)) { |
| 10 | return new int[] {map.get(complement), i}; |
| 11 | } |
| 12 | |
| 13 | map.put(nums[i], i); |
| 14 | } |
| 15 | |
| 16 | return null; |
| 17 | } |
| 18 | } |
nothing calls this directly
no outgoing calls
no test coverage detected