What goes in the blank?
# length of the longest STRICTLY increasing subsequence
from bisect import bisect_left, bisect_right
tails = []
for x in nums:
i = ____(tails, x)
if i == len(tails):
tails.append(x)
else:
tails[i] = x
Answer: bisect_left
bisect_left replaces an equal tail instead of extending past it, so repeats never lengthen the run; bisect_right would count non-decreasing runs.
Play Problem Solving ▸