Meta Variants for Find First & Last Position of Element in Sorted Array (LC34)
1825

Hey y’all! I got another solution for a top 50 Meta question, Leetcode 34 Find First & Last Position of Element in Sorted Array as well as its two variants.

Meta sometimes asks the OG LC problem where they expect you to use both lower- and upper bound binary searches which IMO are pretty tricky.
On top of that, there’s a good chance they throw you one of two curveball variants:

  1. What if you had to return the count of an element? (Yes, you still have to use binary search)
  2. What if you had to return the count of unique elements?

For once, I think the variants are pretty fair extensions of the original Leetcode problem. It’s still a challenging test of binary search knowledge though.

Check it out (or not!):

Reference to the OG LC problem: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/description/

Good luck on your phone screens & onsite loops!

Comments (2)