@@ -0,0 +1,954 @@
+/*%0AGiven an array of integers, find two numbers such that they add up to a specific target number.%0A%0AThe function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.%0A%0AYou may assume that each input would have exactly one solution.%0A%0AInput: numbers=%7B2, 7, 11, 15%7D, target=9%0AOutput: index1=1, index2=2%0A*/%0A%0Apackage P1_TwoSum;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class Solution %7B%0A    public  int%5B%5D twoSum(int%5B%5D nums, int target) %7B%0A       int%5B%5D res = new int%5B2%5D;%0A       Map%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();%0A       for(int i=0; i%3Cnums.length;i++)%7B%0A    %09   if(map.containsKey(target-nums%5Bi%5D))%7B%0A    %09%09   res%5B1%5D=i+1;%0A    %09%09   res%5B0%5D=map.get(target-nums%5Bi%5D)+1;%0A    %09%09   return res;%0A    %09   %7D%0A    %09   map.put(nums%5Bi%5D, i);%0A       %7D   %0A       return res;%0A    %7D%0A    %0A%7D%0A

add p1