3 return indices of the two numbers such that they add up to a specific target.

for(int i=0;i<nums.length;i++){

  int component = target-nums[i];

  if(map.containsKey(component))

    return new int[]{map.get(component),i};

  map.put(nums[i],i);

}

原文地址:https://www.cnblogs.com/JaneSJ/p/5910130.html