public class Solution {
/**
*
* @param numbers int整型一维数组
* @param target int整型
* @return int整型一维数组
*/
public int[] twoSum (int[] numbers, int target) {
// write code here
HashMap<Integer,Integer> maps=new HashMap<>();
int index=0;
for(int i=0;i<numbers.length;i++){
if(!maps.containsKey(target-numbers[i])){
maps.put(numbers[i],i);
}else{
index=i;
break;
}
}
if(index!=0){
return new int[]{maps.get(target-numbers[index])+1,index+1};
}
return null;
}
}