Loading
Loading
A sorted log of event codes may contain a value many times. A dashboard needs the span of positions covering a particular code.
Return the first and last index of the target as a two-element array, or [-1, -1] if it is absent.
codes = [5, 7, 7, 8, 8, 10], target = 8lower bound of 8first index not less than 8 → 3lower bound of 9first index not less than 9 → 5range[3, 5 - 1] = [3, 4][3, 4]Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(log n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Example 2
Example 3