Chaturmind
LearnDSASystem DesignBlogPremium
Sign inGet started
Chaturmind

Structured learning paths for engineers who want to go deep. Written by practitioners.

Learn

  • Java
  • DSA
  • System Design
  • Spring Boot
  • AI / ML

Company

  • Blog
  • Premium
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Chaturmind. All rights reserved.

Built for engineers who want to go deep.

DSA›Binary Search›Find Minimum in Rotated Sorted Array
MediumBinary Search

Find Minimum in Rotated Sorted Array

binary-searcharray

Problem

Suppose an array of length n sorted in ascending order is rotated between 1 and n times. Given the sorted rotated array nums, return the minimum element.

Examples

Example 1

Input: nums = [3,4,5,1,2]

Output: 1

Example 2

Input: nums = [4,5,6,7,0,1,2]

Output: 0

Constraints

  • •n == nums.length
  • •1 <= n <= 5000
  • •All values of nums are unique.

Hints

Hint 1

The minimum is at the inflection point. If mid > right, minimum is in the right half.

Solutions

public int findMin(int[] nums) {
    int left = 0, right = nums.length - 1;
    while (left < right) {
        int mid = left + (right - left) / 2;
        if (nums[mid] > nums[right]) left = mid + 1;  // min is in right half
        else                         right = mid;      // mid might be the min
    }
    return nums[left];
}
Java

Time: O(log n) · Space: O(1)