Loading…
Loading…
Given a sorted array that may contain duplicates and a target, return the first and last index of the target, space-separated. Print -1 -1 if the target isn't present.
Input: nums = 5 7 7 8 8 10, target = 8
Output: 3 4
Two binary searches: one biased to find the leftmost occurrence (keep searching left even after a match), one biased to find the rightmost.
Line 1: the array, space-separated Line 2: target
Input (stdin)
Output
Input (stdin)
Output
Sign in to track solved problems and earn XP.