Soal
00:00

19. Search in Rotated Sorted Array

SedangPencarian binerAmazonGoogleMicrosoft

The integer array nums was sorted in ascending order and then rotated. Find the index of target in O(log n) time, or return -1 if it is absent.

Contoh 1:

Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4

Contoh 2:

Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1

Batasan:

  • 1 <= nums.length <= 5000
  • All values in nums are unique.
Mode kode inti
● Tersimpan otomatisBaris 1, kolom 1