System Design Interview Question: DESIGN A PARKING LOT – asked at Google, Facebook

Video is ready, Click Here to View ×

In-depth system discussion of a popular coding interview question, chapters:
0:32 Problem statement
0:55 Finding a solution
2:43 Questions to ask
6:35 Object oriented design/class hierarchy
13:57 Coding question approach
23:34 Testing
This system design interview question/how to system design is for software engineers, software developers, web developers, front end engineers, QA engineers, product managers, network engineers equally important. This interview problem can be asked as a coding interview question, system design question or object oriented design question.

Other names for this problem are: Amazon Locker interview question, The Parking Lot interview question, Parking Lot using OO techniques, Object oriented parking lot.


c++ coding


27 thoughts on “System Design Interview Question: DESIGN A PARKING LOT – asked at Google, Facebook”

  1. Didn't really understand why you choose a stack. If stack for car size M represents the various available spots for M, and all these spots are equal, you only need a counter. If you want to store the actual car object, then deletion would happen in O(n) time and a doubly ended linked list with a reference to the actual object stored in the HashMap would give O(1) time.

  2. I've feel relieved now..i thaught im weird used to think same idea..any issue in this world happen can lead to idea and benefit people then can make money with summary is normal people think ordinary idea/act right? intelligent otherwise.Need to find circle who same think of view and attitude.

  3. Really enjoyed this video and the in depth explanation of design problem.
    I Had one question on the class design you chose: Is there a reason why we didnt't chose to have an enum for S,M.L,XL
    vehicle types and instead use specific classes inheriting from Vehicle for vehicle types?

  4. Why look up cars by licence plate? Isn't it more logical to look them up by spot number and only use licence plate for validation to see if there wasn't some sort of a mistake? Because in the end you are not designing a system for handling cars, you are designing a system for handling (reserving and freeing) parking spots. Just have a ticket with spot number and licence plate and since you have set, limited amount of spots you easily check them. You could even keep a very easy track of the first available slot.

  5. Great tutorial, However, I do have a different points on the data structure.

    Stacks: When we're releasing the spot don't we end up in adding the spot at bottom of stack? In worst case we would end up with Time and Space: for single insert O(N). How about priority Queues?

    Hash map: Instead of directly storing with license plate as key. If we store the entry with key as hash(vehicle) and value as <Vehicle(string), spot> we could end up with extending the same hash table for search by Ticket.

    Please Let me know your thoughts.

  6. It's a great explanation. However, this is not a real parking lot. In real life, parking lot doesn't "place" the car, it's the drivers who drive their cars into the parking lot. Another thing is, most of the parking lots don't ask for license plate. In stead, they just print out some sorts of parking pass.

  7. Please make a video on this System design:
    Design online multiplayer generic board game (like chess). How will you store sessions.(RDBMS or REDIS). How will the competitor be chosen and notified(HTTP or what?).
    What are the appropriate classes?

  8. Great Video! I just had one question regarding the use of Stack and HashMap. If I understood correct, the Stack holds the parking Spots and the HashMap stores the Vehicles right? If so, then when the removeVehicle() method is called, we refer to the HashMap and get the Spot back. After that, we also need to remove the spot from the Stack right? And that might not be the top element. I'm just trying to better understand the need for Stack along with the HashMap. Thanks for the video!

  9. Hi,
    Great Video. But can you explain how the wiring of the code will happen. How Vehicle is going to communicate with parking lot. Is there going to be ParkingLotService. I usually face difficult on how class will communicate with each other.
    Can you also explain if we have to put pricing into our system which class will be responsible for it.

  10. Nice explanation guys. What about using ConcurrentHashMap. That was the first thing that came to my mind. Just ConcurrentHashMap, no Stack stuff. So using this sort of map to tell the free spots that we currently have (keys will be the size, value will be the parking spots that we have left).

  11. This is really nice way to approach a design a system problems. Can you also take example of systems like linkedin/twitter which are real time streaming solutions as well as systems like youtube/netflix/amazon prime like systems.
    1. How do you approach a storage requirement?
    I think in big systems storage technology chosen is really important.
    2. Do we need to give estimate of storage required if they give some number
    e.g. on your Twitter there are 100M users and your system should be able to scale upto 200M users for next 3 years.
    3. How do we limit a design such a way that it's not too big but should be able to tell entire story in nutshell way.

    Thanks for your time and looking forward for more solutions and interactions.

Leave a Reply

Your email address will not be published. Required fields are marked *