Searching · Python
Binary Search Range
Problem
Return [first_index, last_index] for target in sorted nums, or [-1, -1] if absent.
Example input
nums = [1, 2, 2, 2, 4], target = 2
Example output
[1, 3]
Constraints
0 <= len(nums) <= 100,000; nums is sorted
Python workspace
Execution uses a timed child process in a temporary directory. It is development-only isolation, not a production sandbox.