The Design Parking System coding problem is a great introductory design task. You need to create a class that manages parking spaces for three types of cars: big, medium, and small. The system is initialized with a fixed number of slots for each size. You then implement an addCar method that checks if a slot of the appropriate type is available and "occupies" it if possible.
Companies like Uber and Amazon use this "Easy" question to screen for basic object-oriented programming (OOP) skills. It tests whether you can represent real-world constraints using simple variables and whether you can write clean, readable code. It's also a test of your ability to follow instructions precisely and handle basic state modification.
The Simulation design pattern or Counting interview pattern is used here. You simply maintain three integer counters (or an array of size 3). When a car arrives, you check if the corresponding counter is greater than zero. If it is, you decrement the counter and return true; otherwise, return false.
Initialize: big=1, medium=1, small=0.
true.false.true.false.For "Easy" design problems, focus on readability. Use a simple array where the index corresponds to the car type (adjusted for 0-indexing) to make your code more concise and professional.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Walking Robot Simulation II | Medium | Solve | |
| Count Tested Devices After Test Operations | Easy | Solve | |
| Design Memory Allocator | Medium | Solve | |
| RLE Iterator | Medium | Solve | |
| Simple Bank System | Medium | Solve |