@@ -0,0 +1,1704 @@
+package problem.twosum;%0A%0Aimport java.util.*;%0A%0Apublic class TwoSum %7B%0A  public static int%5B%5D twoSum(int%5B%5D numbers, int target) %7B%0A    Map%3CInteger, Integer%3E m = new HashMap%3CInteger, Integer%3E();%0A    int n = numbers.length; // count of all numbers %0A    int%5B%5D result = new int%5B2%5D;%0A    %0A    for (int i = 0; i %3C n; i++) %7B%0A      if (m.isEmpty()) %7B // if m is empty%0A        m.put(numbers%5Bi%5D, i);%0A      %7D else %7B // if m is not empty        %0A        Integer key = new Integer(target - numbers%5Bi%5D); // key is the subscript of the number that is complement to the %0A        Integer key2 = new Integer(numbers%5Bi%5D); // key2 is the subscript of number currently%0A        if (m.containsKey(key))%7B%0A          result%5B0%5D = m.get(key).intValue() + 1;%0A          System.out.println(%22index1=%22 + result%5B0%5D);          %0A          result%5B1%5D = i + 1;%0A          System.out.println(%22index2=%22 + result%5B1%5D);%0A          break;%0A        %7D else if (!m.containsKey(key2)) %7B%0A          m.put(key2,i);%0A        %7D else%7B          %0A        %7D%0A      %7D%0A    %7D%0A    return result;%0A  %7D%0A%7D%0A%0A//public int%5B%5D twoSum(int%5B%5D numbers, int target) %7B  %0A//    // Start typing your Java solution below  %0A//    // DO NOT write main() function  %0A//    HashMap%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();  %0A//    int n = numbers.length;  %0A//    int%5B%5D result = new int%5B2%5D;  %0A//    for (int i = 0; i %3C numbers.length; i++)  %0A//    %7B  %0A//        if (map.containsKey(target - numbers%5Bi%5D))  %0A//        %7B  %0A//            result%5B0%5D = map.get(target-numbers%5Bi%5D) + 1;  %0A//            result%5B1%5D = i + 1;  %0A//            break;  %0A//        %7D  %0A//        else  %0A//        %7B  %0A//            map.put(numbers%5Bi%5D, i);  %0A//        %7D  %0A//    %7D  %0A//    return result;  %0A//      %0A//%7D  %0A

Create TwoSum.java