Run two binary searches: one for the leftmost occurrence (lower bound) and one for the rightmost (upper bound).
Lower bound: Find first index where nums[i] >= target.
Upper bound: Find first index where nums[i] > target, then subtract 1.
Alternatively, find lower bound of target and lower bound of target + 1, then subtract 1 from the second result.