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