Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

Example:

1 | Given nums = [2, 7, 11, 15], target = 9, |

**思路**

利用hashmap，key存放数值，value存放出现的位置。从前到后进行遍历，将target值减去当前的值,看是否存在map中,若存在map中则取出相应的标号，退出。

**代码**

1 | public int[] twoSum(int[] nums, int target) { |