@@ -0,0 +1,2499 @@
+//  Copyright 2016 The Minorminor Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A//%0A%0Apackage leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class LeetCode %7B%0A    // Leetcode 27 Remove Element/ runtime beats 73.63%25 of java submissions.%0A    public static int removeElement(int%5B%5D nums, int val) %7B%0A        int newIndex = 0;%0A        int i = 0;%0A        while (i %3C nums.length) %7B%0A            int current = nums%5Bi%5D;%0A            if (current != val) %7B%0A                nums%5BnewIndex++%5D = nums%5Bi%5D;%0A            %7D%0A            i++;%0A        %7D%0A        return newIndex;%0A    %7D%0A%0A%0A    // Leetcode 50 pow(x,n)%0A    // recursion%0A    // the total number of operations is O(logn)%0A    // its memory usage is O(logn) as well.%0A    public static double power(double x, int n) %7B%0A        if (x == 1) %7B%0A            return 1;%0A        %7D%0A%0A        if (x == -1) %7B%0A            return (n & 1) == 1 ? -1 : 1;%0A        %7D%0A%0A        boolean negative = false;%0A        if (n %3C 0) %7B%0A            negative = true;%0A            n = -n;%0A        %7D%0A%0A        if (n == 0) %7B%0A            return 1;%0A        %7D%0A        double result = power(x, n %3E%3E 1);%0A        result *= result;%0A        if ((n & 1) == 1) %7B%0A            result *= x;%0A        %7D%0A        return negative ? 1 / result : result;%0A    %7D%0A%0A    // Leetcode 50 pow(x,n)%0A    // nonrecursive implementation%0A    // its not the fast one, only runtime beats 29.88%25 of java submissions on 2/1/2016.%0A    static double power2(double x, int n) %7B%0A        if (x == 1) %7B%0A            return 1;%0A        %7D%0A%0A        if (x == -1) %7B%0A            return (n & 1) == 1 ? -1 : 1;%0A        %7D%0A%0A        boolean negative = false;%0A        if (n %3C 0) %7B%0A            negative = true;%0A            n = -n;%0A        %7D%0A%0A        double result = 1;%0A        while (n %3E 0) %7B%0A            if ((n & 1) == 1) %7B%0A                result *= x;%0A            %7D%0A            x *= x;%0A            n %3E%3E= 1;%0A        %7D%0A        List newone = new ArrayList(9);%0A        return negative ? 1 / result : result;%0A    %7D%0A%7D%0A

Add Leetcode 50 pow(x,n)