@@ -0,0 +1,1016 @@
+public class FirstMissingPositive %7B%0A    /**Thought:%0A     * 1 - most sorting algorithms take time at least O(nlogn).%0A     * 2 - Linear sorting algorithm bucket sort requires O(n) space%0A     * 3 - HashTable also take O(n) space%0A     * @param A: an array of integers%0A     * @return: an integer%0A     */%0A    public int findFirstMissingPositive(int%5B%5D A) %7B%0A        if (A == null) %7B%0A            return 0;%0A        %7D%0A        %0A        for (int i = 0; i %3C A.length; i++) %7B%0A            // 1: A%5Bi%5D is in the range%0A            // 2: A%5Bi%5D %3E 0%0A            // 3: The target is different%0A            while (A%5Bi%5D %3E 0 && A%5Bi%5D %3C= A.length && A%5BA%5Bi%5D - 1%5D != A%5Bi%5D) %7B%0A                swap(i, A%5Bi%5D - 1, A);%0A            %7D%0A        %7D%0A        %0A        for (int i = 0; i %3C A.length; i++) %7B%0A            if (A%5Bi%5D != i + 1) %7B%0A                return i + 1;%0A            %7D%0A        %7D%0A        %0A        return A.length + 1;%0A    %7D%0A    %0A    private void swap (int i, int j, int%5B%5D A) %7B%0A        int tmp = A%5Bi%5D;%0A        A%5Bi%5D = A%5Bj%5D;%0A        A%5Bj%5D = tmp;%0A    %7D%0A%7D%0A

Create FirstMissingPositive.java