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:
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.
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!