package leetcode;

/**
 * https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
 */
public class Problem81 {
    public boolean search(int[] nums, int target) {
        return false;
    }
    
    public static void main(String[] args) {
        Problem81 prob = new Problem81();
//        System.out.println(prob.search(nums, target));
    }
}

@@ -177,22 +177,182 @@
     
-return false;%0A
+int prev = 0;%0A        int current;%0A        for (current = 1; current %3C nums.length; current++) %7B%0A            if (nums%5Bcurrent%5D %3C nums%5Bprev%5D) %7B%0A                break;%0A        
     
@@ -361,150 +361,813 @@
     
-%0A
+ 
     
-public static void main(String%5B%5D args) %7B
+   prev = current;%0A        %7D%0A        int startIdx = current;%0A        if (current == nums.length) %7B%0A            startIdx = 0;%0A        %7D%0A        int result = binarySearch(nums, target, 0, nums.length-1, startIdx);%0A        return result != -1;
 %0A    
+%7D%0A%0A
     
-Problem81 prob = new Problem81();%0A//        System.out.println(prob.search(nums, target)
+private int binarySearch(int%5B%5D nums, int target, int lo, int hi, int startIdx) %7B%0A        if (lo %3E hi) %7B%0A            return -1;%0A        %7D%0A        int mid = (lo + hi) / 2;%0A        int midIdx = startIdx + mid;%0A        if (midIdx %3E= nums.length) %7B%0A            midIdx = midIdx - nums.length;%0A        %7D%0A        if (nums%5BmidIdx%5D == target) %7B%0A            return midIdx;%0A        %7D%0A        if (nums%5BmidIdx%5D %3E target) %7B%0A            return binarySearch(nums, target, lo, mid-1, startIdx);%0A        %7D%0A        return binarySearch(nums, target, mid+1, hi, startIdx
 );%0A 

Solve problem 81