Code Room
CodingMediumcod-g1460
Subject IntervalsLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.