Given a rotated sorted array of distinct integers, return the minimum element in the array. The array was originally sorted in ascending order and then rotated at some unknown pivot. The task is to find the smallest element efficiently
Example 1
Input: nums = [3,4,5,1,2]
Output: 1
Explanation: The original sorted array was [1,2,3,4,5], which was rotated. The smallest element is 1.
Example 2
Input: nums = [4,5,6,7,0,1,2]
Output: 0
Explanation: The smallest element in the rotated array is 0.
Example 3
Input: nums = [11,13,15,17]
Output: 11
Explanation: The array is already sorted and not rotated. The first element is the minimum.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
3 4 5 1 2
1
4 5 6 7 0 1 2
0
11 13 15 17
11