@@ -0,0 +1,1364 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * https://oj.leetcode.com/problems/two-sum/%0A */%0Apublic class Problem1 %7B%0A    public int%5B%5D twoSum(int%5B%5D numbers, int target) %7B%0A        Map%3CInteger, List%3CInteger%3E%3E map = new HashMap%3C%3E();%0A        for (int i = 0; i %3C numbers.length; i++) %7B%0A            if (!map.containsKey(numbers%5Bi%5D)) %7B%0A                map.put(numbers%5Bi%5D, new ArrayList%3CInteger%3E());%0A            %7D%0A            map.get(numbers%5Bi%5D).add(i);%0A        %7D%0A        Arrays.sort(numbers);%0A        for (int i = 0; i %3C numbers.length; i++) %7B%0A            int val = target - numbers%5Bi%5D;%0A            int j = Arrays.binarySearch(numbers, i, numbers.length, val);%0A            if (j %3C 0) %7B%0A                continue;%0A            %7D else %7B%0A                if (numbers%5Bi%5D == numbers%5Bj%5D) %7B%0A                    int a = map.get(numbers%5Bi%5D).get(0) + 1;%0A                    int b = map.get(numbers%5Bi%5D).get(1) + 1;%0A                    return (a %3C b) ? new int%5B%5D%7Ba, b%7D : new int%5B%5D%7Bb, a%7D;%0A                %7D else %7B%0A                    int a = map.get(numbers%5Bi%5D).get(0) + 1;%0A                    int b = map.get(numbers%5Bj%5D).get(0) + 1;%0A                    return (a %3C b) ? new int%5B%5D%7Ba, b%7D : new int%5B%5D%7Bb, a%7D;%0A                %7D%0A            %7D%0A        %7D%0A        return new int%5B%5D%7B%7D;%0A    %7D%0A%7D%0A

Solve problem 1