Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Design Parking System

Easy

Topics
DesignCountingSimulation

Design a parking system for a lot with three kinds of spaces: big, medium, and small, with a fixed number of each. Implement ParkingSystem(big, medium, small) and addCar(carType) where carType is 1 (big), 2 (medium), or 3 (small). Return true if there is an available slot of that type (and park the car), otherwise false.

Example 1

Input:  operations = ["ParkingSystem","addCar","addCar","addCar","addCar"], values = [[1,1,0],[1],[2],[3],[1]]
Output: [null,true,true,false,false]

Constraints

  • 0 <= big, medium, small <= 1000
  • carType is 1, 2, or 3.
  • At most 1000 calls to addCar.
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access