classSolution{ publicint[] twoSum(int[] nums, int target) { int[] result = newint[2];
Map<Integer,Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { if(map.containsKey(target-nums[i])){ int value = map.get(target-nums[i]); result[0] = value; result[1] = i; break; } map.put(nums[i],i); }