03 · OOP for DSA & Design Rounds

#1603 Design Parking System

Easysolve on LeetCode ↗

frequently reported atAmazon

the problem

In plain words

A parking lot has a fixed number of big, medium and small slots, given to the constructor ParkingSystem(big, medium, small). addCar(carType) (1 = big, 2 = medium, 3 = small) parks the car in a free slot of exactly its size and returns true, or returns false if none is free.

in ParkingSystem(1, 1, 0); addCar(1), addCar(2), addCar(3), addCar(1)

out true, true, false, false

There is no small slot at all, and the only big slot is taken by the first car.

  • 0 ≤ big, medium, small ≤ 1000
  • carType is 1, 2 or 3
  • At most 1000 calls to addCar

your turn

Try it before you peek

Read the examples, say the brute force out loud, then write code: here or on LeetCode ↗. Stuck for 20 minutes? Open one hint at a time.

Solve it in the browser

Design: implement every operation. Compiled by the real javac (Java 17) and judged right here — nothing is sent anywhere.

    Solutions are hidden so you can try first. Even 20 minutes of real effort makes the answer stick far better than reading it.

    Marking the problem solved, or opening every hint, also shows it.

    practise next

    Similar problems

    1. #622
      Design Circular Queue
      Mediumin Queues
    2. #155
      Min Stack
      Mediumin Stacks
    3. #705
      Design HashSet
      Easyin Java OOP