/**
 * Suppose a sorted array is rotated at some pivot unknown to you beforehand.
 * (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
 * 
 * Find the minimum element.
 * You may assume no duplicate exists in the array.
 * 
 * Tags: Array, Binary Search
 */
class FindRotatedArrMin {
    public static void main(String[] args) {
        int[] num = { 3, 4, 5, 6, 0, 1, 2 };
        // int[] num = { 4, 5, 6, 7, 0, 1, 2 };
        System.out.println(findMin(num));
    }
    
    static int findMin(int[] num) {
        int l = 0;
        int r = num.length - 1;
        if (num.length == 1 || num[l] < num[r]) return num[0];
        
        int mid = 0;
        while (l < r) {
            mid = l + (r - l) / 2;
            System.out.println(mid);
            if (num[l] < num[mid]) l = mid;
            else r = mid;
        }
        return num[l + 1];
    }
    
}
@@ -660,71 +660,572 @@
     
-while (l %3C r) %7B%0A            mid = l + (r - l) / 2;%0A            
+%0A        /* There's n-1 pairs of adjacent nodes.%0A         * Rotation brings one pair with reverse order.%0A         * If the original sequence is in ascending order, the special one is max-min.%0A         * Any range %5Bleft,right%5D contains this pair must satisify num%5Bleft%5D %3E num%5Bright%5D.%0A         * num%5Bright%5D %3C num%5B0%5D %3C num%5Bleft%5D.%0A         * Try to capture this range with Binary Search.%0A         */        %0A        while (l %3C r) %7B%0A            mid = l + (r - l) / 2;%0A            if(num%5Bl%5D %3E num%5Bmid%5D) r = mid;%0A            else l = mid; //no dups. no %22=%22%0A            //
 Syst
@@ -1253,24 +1253,26 @@
             
+//
 if (num%5Bl%5D %3C
@@ -1299,24 +1299,26 @@
             
+//
 else r = mid
@@ -1355,16 +1355,31 @@
 %5Bl + 1%5D;
+ //l:max, r:min
 %0A    %7D%0A 

Update implementation.