力扣https://leetcode-cn.com/problems/two-sum/
class Solution {
public int[] twoSum(int[] nums, int target) {
int[] result = new int[2];
Map<Integer,Integer> map = new HashMap<>();
for(int i = 0;i<nums.length;i++){
int value = nums[i];
int minusValue = target - value;
if(map.containsKey(minusValue)){
result[0] = map.get(minusValue);
result[1] = i;
break;
}else{
map.put(value,i);
}
}
return result;
}
}