23. Find Minimum in Rotated Sorted Array

A sorted array of distinct values was rotated at some unknown pivot (for example [1,2,3,5,6,7] → [5,6,7,1,2,3]). Return the smallest value in O(log n).

Example 1

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

Example 2

Input: nums = [2,1]
Output: 1
Hint 1

Compare the middle element with the last element.

Hint 2

If nums[mid] > nums[hi], the rotation point (the minimum) is to the right.

Binary Search