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 .
Alternatively, find lower bound of target and lower bound of target + 1, then subtract from the second result.