@@ -0,0 +1,1132 @@
+import java.math.BigInteger;%0A%0A/**%0A * Problem: #278 First Bad Version%0A *%0A * Idea:%0A *%0A * Solutions:%0A *  firstBadVersion: uses basic binary search, but StackOverflowError occurs.%0A *%0A * Note: #canbefaster%0A */%0A%0A/* The isBadVersion API is defined in the parent class VersionControl.%0A      boolean isBadVersion(int version); */%0Apublic class FirstBadVersion %7B%0A    public int binarySearch(int left, int right) %7B%0A        int middle = (left + right)/2;%0A%0A        if (isBadVersion(middle)  == true) %7B%0A            if (isBadVersion(middle - 1) == false) %7B%0A                return middle;%0A            %7D else %7B%0A                return binarySearch(left, middle-1);%0A            %7D%0A        %7D%0A%0A        if (isBadVersion(middle) == false) %7B%0A            return binarySearch(middle + 1, right);%0A        %7D%0A%0A        return -1;%0A    %7D%0A%0A    public int firstBadVersion(int n) %7B%0A        return binarySearch(1, n);%0A    %7D%0A%0A    private boolean isBadVersion(int n) %7B%0A        if (n %3E= 1702766719) return true;%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(new FirstBadVersion().firstBadVersion(2126753390));%0A    %7D%0A%7D%0A

Add new solution but StackOverflowError exists