Code RoomMinimum parking spots needed
MediumPrep Room Coding #661

Minimum parking spots needed

CodingAlgorithms & data structuresEntry–Mid~15 min

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]]) → int
Examples
in[[[0,30],[5,10],[15,20]]]out2
What 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
InputExpectedGot
[[[0,30],[5,10],[15,20]]]2not run yetsample