Find Minimum in Rotated Sorted Array II LeetCode solution in Java
1class Solution {2public int findMin(int[] nums) {3int l = 0;4int h = nums.length - 1;5while (l < h) {6while (l < h && nums[l] == nums[l + 1]) ++l;7while (l < h && nums[h] == nums[h - 1]) --h;8int mid = l + (h - l) / 2;9if (nums[mid] > nums[h]) { // smaller elements are in the right side10l = mid + 1;11} else {12h = mid;13}14}15return nums[l];16}17}