Find First and Last Position of Element in Sorted Array || Leetcode Medium 34 || Binary Search

Опубликовано: 24 Июль 2026
на канале: Digital Interview
32
3

Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

If target is not found in the array, return [-1, -1].

You must write an algorithm with O(log n) runtime complexity.

Binary Search solution:    • Find First and Last Position of Element in...  


Example 1:

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

Get notified about all off campus jobs/interviews and the process.
We are building our website and it will be back soon with lots of content till then subscribe us on youtube.
https://t.me/tech_geek1

Interview Preparation Sheet:    • INTERVIEW PREPARATION SHEET - HASHEDIN and...  

Link for Leetcode solutions:    • Leetcode Solutions  

Link for placement series:
Placement 2022:    • Placements 2022  
Placement 2023:    • Placements 2023  

#leetcode #leetcodesolution