@Test public void twoSumTest2() { final int[] testSrc = {}; final int[] result = problem.solution001(testSrc, 0); Assert.assertNull(result); }
public int[] solution001(int[] nums, int target) { final Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { final int delta = target - nums[i]; if (!map.containsKey(delta)) { map.put(nums[i], i); continue; } return new int[] {map.get(delta), i}; } return null; }
Problem0001TwoSum { public int[] solution001(int[] nums, int target) { final Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { final int delta = target - nums[i]; if (!map.containsKey(delta)) { map.put(nums[i], i); continue; } return new int[] {map.get(delta), i}; } return null; } }
Problem0001TwoSum { public int[] solution001(int[] nums, int target) { final Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { final int delta = target - nums[i]; if (!map.containsKey(delta)) { map.put(nums[i], i); continue; } return new int[] {map.get(delta), i}; } return null; }  }
Problem0001TwoSum { public int[] solution001(int[] nums, int target) { final Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { final int delta = target - nums[i]; if (!map.containsKey(delta)) { map.put(nums[i], i); continue; } return new int[] {map.get(delta), i}; } return null; }  int[] solution001(int[] nums, int target); int[] solution002(int[] nums, int target); }
Problem0001TwoSum { public int[] solution001(int[] nums, int target) { final Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { final int delta = target - nums[i]; if (!map.containsKey(delta)) { map.put(nums[i], i); continue; } return new int[] {map.get(delta), i}; } return null; }  int[] solution001(int[] nums, int target); int[] solution002(int[] nums, int target);  }