← All problems

Find First and Last Position in Sorted Array

Medium searchingarrays LeetCode ↗
Find the start/end indices of target in sorted array; [-1,-1] if absent.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(log n), Space O(1)

Common pitfalls

  • Linear expansion after find (O(n) worst)
  • Off-by-one in bound variants

Your solution

Log in to save your code and track progress.