Find Minimum in Rotated Sorted Array

Advanced

Let's imagine you have a magical array of numbers that was once sorted in increasing order but then was magically rotated, meaning that the smallest number is no longer at the start.

Your task is to write a function to find the smallest number in this rotated array. Let's call it find_min. The array has been rotated at some unknown pivot. The cool part is that it won't have any duplicates!

Here is how it should work:

If you have the array [3, 4, 5, 1, 2], the smallest number is 1 as the original sorted array could have been [1, 2, 3, 4, 5] before it was rotated.

Examples

find_min([4, 5, 6, 7, 0, 1, 2]) # Returns: 0 find_min([3, 4, 5, 1, 2]) # Returns: 1 find_min([1, 2, 3, 4, 5, 6, 7]) # Returns: 1 find_min([2, 3, 4, 5, 6, 7, 0, 1]) # Returns: 0

Time to put on your problem-solving hat and find that minimum number like a coding wizard!

Geek
Inputs

Arg 1:

[4,5,6,7,0,1,2]
Expected Output
0
Actual Output
Find Minimum in Rotated Sorted Array [advanced] | Coding for Kids