Skip to content

Latest commit

 

History

History
11 lines (6 loc) · 430 Bytes

Shifted_Array_Search.md

File metadata and controls

11 lines (6 loc) · 430 Bytes

#Shifted Array Search

Find a given number num in a sorted array arr:

arr = [2, 4, 5, 9, 12, 17]

If the sorted array arr is shifted left by an unknown offset and you don't have a pre-shifted copy of it, how would you modify your method to find a number in the shifted array?

shiftArr = [9, 12, 17, 2, 4, 5]

Explain and code an efficient solution and analyze its runtime complexity if num doesn't exist in the array, return -1