(int[] nums, int target)
| 1 | public class Solution { |
| 2 | // example in leetcode book |
| 3 | public int[] twoSum(int[] nums, int target) { |
| 4 | Map<Integer, Integer> map = new HashMap<>(); |
| 5 | for (int i = 0; i < nums.length; i++) { |
| 6 | int x = nums[i]; |
| 7 | if (map.containsKey(target - x)) { |
| 8 | return new int[]{map.get(target - x), i}; |
| 9 | } |
| 10 | map.put(x, i); |
| 11 | } |
| 12 | throw new IllegalArgumentException("No two sum solution"); |
| 13 | } |
| 14 | } |
nothing calls this directly
no test coverage detected