Find First and Last Position of Element in Sorted Array — Interactive Visualizer

Run binary search twice: once for the left boundary and once for the right boundary of the target.