Interval containment check
Given a list of closed integer intervals, return True if some interval completely contains another one at a different index: interval [a, b] contains [c, d] when a <= c and d <= b. Two identical intervals count as containing each other. The list holds at most a few thousand intervals, so a quadratic scan is acceptable. Example: [[1,6],[2,4],[7,9]] is True because [1,6] contains [2,4].
Implement
has_contained_interval(intervals: list[list[int]]) → boolExamples
in
[[[1,6],[2,4],[7,9]]]outtrueWhat a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 11 min
solution.py
InputExpectedGot
[[[1,6],[2,4],[7,9]]]truenot run yetsample