Search in Rotated Sorted Array
Medium · Binary Search · about 20 minutes
Asked at Cisco, Intel, LinkedIn, Meta, Microsoft, Oracle, Roblox, Uber, AMD, IBM, Broadcom, Arista Networks, Palo Alto Networks, Epic Games, Riot Games, Electronic Arts, Unity, SpaceX, Dell Technologies, Micron, SAP, Zscaler, Nutanix, Rubrik, Akamai.
A sorted array of distinct integers has been rotated at an unknown pivot (e.g. [4,5,6,7,0,1,2]). Find the index of a target value in O(log n), or -1.