62. Find minimum in Rotated Sorted Array

Given an integer array nums of size N, sorted in ascending order with distinct values, and then rotated an unknown number of times (between 1 and N), find the minimum element in the array.

Example 1:

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

Output: 0

Explanation: Here, the element 0 is the minimum element in the array.

Example 2:

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

Output: 1

Explanation:Here, the element 1 is the minimum element in the array.

Now Your Turn!

Pick the correct output for the given input

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

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • n == nums.length
  •  1 <= n <= 104
  •  -104 <= nums[i] <= 104
  •  All the integers of nums are unique.
  •  nums is sorted and rotated between 1 and n times.

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
int findMin(vector<int> &arr) {
}
};
Test Case

Input:

Nums