```
public class Solution {
public int[] twoSum(int[] nums, int target) {
HashMap<Integer, Integer> numbers = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
Integer idx2 = numbers.get(target - nums[i]);
if (idx2 != null) return new int[]{idx2, i};
numbers.put(nums[i], i);
}
return null;
}
}
```