Same as Find Minimum in Rotated Sorted Array but the array may contain duplicates. Return the minimum element.

Input: [1,3,5] → Output: 1Input: [2,2,2,0,1] → Output: 0

Similar to version I but when nums[mid] == nums[hi] we cannot determine which half contains the minimum, so we decrement hi by 1.

class Solution { public int findMin(int[] nums) { int lo = 0, hi = nums.length - 1; while (lo < hi) { int mid = lo + (hi - lo) / 2; if (nums[mid] > nums[hi]) lo = mid + 1; else if (nums[mid] < nums[hi]) hi = mid; else hi--; } return nums[lo]; } }