Stealth Interview
  • Features
  • Pricing
  • Blog
  • Login
  • Sign up

Leetcode #1603: Design Parking System

In this guide, we solve Leetcode #1603 Design Parking System in Python and focus on the core idea that makes the solution efficient.

You will see the intuition, the step-by-step method, and a clean Python implementation you can use in interviews.

Leetcode

Problem Statement

Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size.

Quick Facts

  • Difficulty: Easy
  • Premium: No
  • Tags: Design, Counting, Simulation

Intuition

The output depends on how often values appear.

Counting frequencies lets us answer queries in constant time afterward.

Approach

Count occurrences with a map or array, then compute the result from those counts.

This avoids repeated scans of the input.

Steps:

  • Count frequencies.
  • Use counts to compute result.
  • Return the computed value.

Example

Input ["ParkingSystem", "addCar", "addCar", "addCar", "addCar"] [[1, 1, 0], [1], [2], [3], [1]] Output [null, true, true, false, false] Explanation ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0); parkingSystem.addCar(1); // return true because there is 1 available slot for a big car parkingSystem.addCar(2); // return true because there is 1 available slot for a medium car parkingSystem.addCar(3); // return false because there is no available slot for a small car parkingSystem.addCar(1); // return false because there is no available slot for a big car. It is already occupied.

Python Solution

class ParkingSystem: def __init__(self, big: int, medium: int, small: int): self.cnt = [0, big, medium, small] def addCar(self, carType: int) -> bool: if self.cnt[carType] == 0: return False self.cnt[carType] -= 1 return True # Your ParkingSystem object will be instantiated and called as such: # obj = ParkingSystem(big, medium, small) # param_1 = obj.addCar(carType)

Complexity

The time complexity is O(1)O(1)O(1), and the space complexity is O(1)O(1)O(1). The space complexity is O(1)O(1)O(1).

Edge Cases and Pitfalls

Watch for boundary values, empty inputs, and duplicate values where applicable. If the problem involves ordering or constraints, confirm the invariant is preserved at every step.

Summary

This Python solution focuses on the essential structure of the problem and keeps the implementation interview-friendly while meeting the constraints.


Ace your next coding interview

We're here to help you ace your next coding interview.

Subscribe
Stealth Interview
© 2026 Stealth Interview®Stealth Interview is a registered trademark. All rights reserved.
Product
  • Blog
  • Pricing
Company
  • Terms of Service
  • Privacy Policy