find two elements in the array which produce a sum equals to a specific target sum
Sigiloso
there are plenty of ready made solutions in the Internet, but here is one of them public static int[] method(int[] nums, int target) { Map map = new HashMap(); for (int i = 0; i < nums.length; i++) { int complement = target - nums[i]; if (map.containsKey(complement)) { return new int[]{map.get(complement), i}; } map.put(nums[i], i); } throw new IllegalArgumentException(); }