Sorted But Never Stated
A teammate hands you this helper and asks you to call it from your code.
def first_at_least(a, x):
"""Return the smallest index i with a[i] >= x,
or len(a) if every element is smaller than x.
Runs in O(log n).
"""
The docstring never uses the word "sorted". Which obligation does the caller nevertheless have to satisfy, and what in the docstring is the only clue that it exists?
Sign in to answer questions and track your progress
Sign In