class{ publicint[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<>(); int[] res = {-1, -1}; if (nums == null || nums.length < 2) { return res; } for (int i = 0; i < nums.length; i++) { int a = nums[i]; int b = target - nums[i]; if (map.containsKey(b)) { int j = map.get(b); res = newint[]{i, j}; break; } map.put(a, i); } return res; } }