@@ -0,0 +1,1257 @@
+/*%0A * Leetcode 1: Two Sum%0A * https://leetcode.com/problems/two-sum/%0A * Martin.Xia%0A */%0A%0A/* %0A * If the input array numbers are sorted in ascending order, %0A * we could use the following method%0A *%0Apublic class Solution %7B%0A    public int%5B%5D twoSum(int%5B%5D numbers, int target) %7B%0A        int%5B%5D result = new int%5B2%5D;%0A        int start = 0;%0A        int end = numbers.length-1;%0A        while(start%3Cend)%7B%0A            if(numbers%5Bstart%5D+numbers%5Bend%5D%3Ctarget)%7B%0A                start++;%0A            %7D%0A            else if(numbers%5Bstart%5D+numbers%5Bend%5D%3Etarget)%7B%0A                end--;%0A            %7D%0A            else%7B%0A                result%5B0%5D = start+1;%0A                result%5B1%5D = end+1;%0A                break;%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%7D%0A*/%0A%0Apublic class Solution %7B%0A    public int%5B%5D twoSum(int%5B%5D numbers, int target) %7B%0A    HashMap%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();%0A    int%5B%5D result = new int%5B2%5D;%0A %0A    for (int i = 0; i %3C numbers.length; i++) %7B%0A        if (map.containsKey(numbers%5Bi%5D)) %7B%0A            int index = map.get(numbers%5Bi%5D);%0A            result%5B0%5D = index+1 ;%0A            result%5B1%5D = i+1;%0A            break;%0A        %7D else %7B%0A            map.put(target - numbers%5Bi%5D, i);%0A        %7D%0A    %7D%0A %0A    return result;%0A    %7D%0A%7D%0A%0A%0A%0A%0A%0A%0A%0A

Leetcode 1: Two Sum