Find First and Last Position of Element in Sorted Array (LC #34) is a top Meta question. Run binary search twice: once to find the leftmost occurrence (when arr[mid] equals target, continue searching left), once for the rightmost (continue searching right). Return both positions. This runs in time and space. Meta asks variants: return the count of the element, count of unique elements in a range. The two-bound pattern is core for any range query in sorted data.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/sorting-searching/find-first-and-last-position
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████████████████