@@ -0,0 +1,1427 @@
+/**%0A *%09Follow up for %22Find Minimum in Rotated Sorted Array%22:%0A *%09What if duplicates are allowed?%0A *%0A *%09Would this affect the run-time complexity? How and why?%0A *%09Suppose a sorted array is rotated at some pivot unknown to you beforehand.%0A *%0A *%09(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).%0A *%0A *%09Find the minimum element.%0A *%0A *%09The array may contain duplicates.%0A *%0A *%09Author: matao%0A *%0A */%0A%0Apublic class FindMinimumInRotatedSortedArrayII %7B%0A%09public static int findMin(int%5B%5D nums) %7B%0A        int start = 0, end = nums.length - 1;%0A%0A        //  %E9%A6%96%E4%BD%8D%E6%95%B0%E5%AD%97%E7%9B%B8%E5%90%8C%E6%83%85%E5%86%B5%EF%BC%8C%E6%97%A0%E6%B3%95%E8%BF%9B%E8%A1%8C%E6%8A%98%E5%8D%8A%EF%BC%8C%E6%95%85%E4%B8%80%E8%B6%9F%E5%BE%AA%E7%8E%AF%0A        if(nums%5Bstart%5D == nums%5Bend%5D) %7B%0A        %09int result = nums%5B0%5D;%0A        %09for(int i = 1; i %3C nums.length; i++) %7B%0A        %09%09if(result %3E nums%5Bi%5D) %7B%0A        %09%09%09result = nums%5Bi%5D;%0A        %09%09%7D%0A        %09%7D%0A        %09return result;%0A        %7D%0A%0A        while(start + 1 %3C end) %7B%0A            int mid = start + (end - start) / 2;%0A            if(nums%5Bmid%5D %3E nums%5Bend%5D) %7B%0A                start = mid;%0A            %7D else %7B%0A            %09end = mid;%0A            %7D%0A        %7D%0A%0A        if(nums%5Bstart%5D %3C nums%5Bend%5D) %7B%0A        %09return nums%5Bstart%5D;%0A        %7D else %7B%0A        %09return nums%5Bend%5D;%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09int%5B%5D nums1 = %7B1, 2, 2, 2, 2%7D;%0A%09%09int%5B%5D nums2 = %7B4, 5, 5, 6, 7, 0, 1, 2, 2%7D;%0A%09%09int%5B%5D nums3 = %7B1, 1, 2, 3%7D;%0A%09%09System.out.println(findMin(nums1));%0A%09%09System.out.println(findMin(nums2));%0A%09%09System.out.println(findMin(nums3));%0A    %7D%0A%7D

add Find Minimum in Rotated Sorted Array II solution