@@ -0,0 +1,1508 @@
+import java.util.*;%0A%0A/**%0A * Problem: https://leetcode.com/problems/two-sum/%0A * %0A * Computation Complexity: O(nlog(n))%0A * %0A * Travel through the array, then using binary search to find the mate number, which two could sum to target.%0A */%0A%0Apublic class Solution %7B%0A    public int%5B%5D twoSum(int%5B%5D array, int target) %7B%0A        Combo%5B%5D nums = new Combo%5Barray.length%5D;%0A        for(int i=0; i%3Carray.length; i++)%7B%0A            nums%5Bi%5D = new Combo(array%5Bi%5D, i);%0A        %7D%0A        Arrays.sort(nums);%0A        for(int i=0; i%3Cnums.length; i++) %7B%0A            int a = target - nums%5Bi%5D.number;%0A            int j=i+1;%0A            int k = nums.length-1;%0A            while(j%3C=k)%7B%0A                int mid = (j+k)/2;%0A                if(a == nums%5Bmid%5D.number) %7B%0A                    if(nums%5Bi%5D.index %3C nums%5Bmid%5D.index) return new int%5B%5D%7Bnums%5Bi%5D.index + 1,nums%5Bmid%5D.index + 1%7D;%0A                    else return new int%5B%5D%7Bnums%5Bmid%5D.index + 1,nums%5Bi%5D.index + 1%7D;%0A                %7D else if (a%3Enums%5Bmid%5D.number)%7B%0A                    j = mid + 1;%0A                %7D else %7B%0A                    k = mid - 1;%0A                %7D%0A            %7D%0A        %7D%0A        return new int%5B2%5D;%0A    %7D%0A%7D%0A%0Aclass Combo implements Comparable%7B%0A    public int number;%0A    public int index;%0A    %0A    Combo(int n, int idx) %7B%0A        number = n;%0A        index = idx;%0A    %7D%0A    %0A    public int compareTo(Object a) %7B%0A        Combo other = (Combo)a;%0A        if(this.number == other.number) return this.index - other.index;%0A        return this.number - other.number;%0A    %7D%0A %0A%7D%0A

Create Two_Sum.java