Soal
00:00

20. Find First and Last Position of Element in Sorted Array

SedangPencarian binerAmazonMicrosoft

Given an integer array nums sorted in ascending order and a target, return the starting and ending position of target, or [-1, -1] if it is absent.

Contoh 1:

Input: nums = [5,7,7,8,8,10], target = 8
Output: [3,4]

Contoh 2:

Input: nums = [5,7,7,8,8,10], target = 6
Output: [-1,-1]

Batasan:

  • 0 <= nums.length <= 10^5
  • nums is sorted in ascending order.
Mode kode inti
● Tersimpan otomatisBaris 1, kolom 1