Study Notes
Problem editorialmedium

First and last position of a value

One binary search finds an occurrence. To pin down the edges of a run of duplicates, don’t stop when you find it — keep leaning toward the boundary.

19 min read·time O(log n)·space O(1)
Boundary searchLeandon't stopTwo passes