Minimum parking spots needed
A parking garage logs each car's visit as [arrive, depart] in minutes; a car holds a spot for the half-open span [arrive, depart), so a car arriving exactly as another departs can take over that spot. Given all visits for a day, return the minimum number of spots the garage needed — equivalently, the maximum number of cars present at any single moment. Example: [[0,30],[5,10],[15,20]] needs 2 spots.
Implement
min_spots(visits: list[list[int]]) → intExamples
in
[[[0,30],[5,10],[15,20]]]out2What 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 15 min
solution.py
InputExpectedGot
[[[0,30],[5,10],[15,20]]]2not run yetsample