Question DSA-SRCH-0062
HardWhat is the output of this code?
import bisect
def first_last(a, t):
l = bisect.bisect_left(a, t)
if l == len(a) or a[l] != t: return (-1, -1)
return (l, bisect.bisect_right(a, t) - 1)
a = [5, 7, 7, 8, 8, 8, 10]
print(first_last(a, 8), first_last(a, 6))
- A.
(3, 5) (1, 1)
- B.
(4, 5) (-1, -1)
- C.
Sign up free to see the answer and a step-by-step explanation.