Search for a target in a rotated sorted array. The array was sorted then rotated at an unknown pivot. Must be O(log n).
Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4
Topics: binary-search, arrays
Asked by: Amazon, Google, Meta, Microsoft, Apple, Bloomberg, Uber
Time complexity: O(log n). Space complexity: O(1).