class Solution {
public int[] twoSum(int[] nums, int target) {
int[] res = new int[2];
Map<Integer, Integer> m = new HashMap<>();
for(int i=0; i< nums.length; i++){
int t = target - nums[i];
if(m.containsKey(t)){
res[0]=i;
res[1]=m.get(t);
}
m.put(nums[i], i);
}
return res;
}
}