Skip to content
Zeni Study
  • Pages
    • Learn Python In 7 Days
      • Day 1 : Variable + if/else
      • Day 2: Loops
      • Day 3 : Array + String
      • Day 4 — Functions
      • Day 5 — Dictionaries - Hashmap
      • Day 6 — Files & Errors
      • Day 7 — Mini Project & Programmer Thinking
    • Machine Coding:
      • Day 1 — Bank account + Wallet :
      • Day 2 : RateLimiter + seat booking
      • Day 3 : Library Management + Classroom Attendance System
      • Day 4 : Bank account and notification system.
      • Day 5 : Key-value and payment processor.
      • Day 6 : Discount engine + Seat booking( in depth)
      • icon picker
        Day 7: Parking lot System :
    • Machine coding extended:
      • Day 7.5 — Parking Lot (Constraint-Heavy Variant)
      • Day 8 : Order + Payment System
      • Day 8 — Extension Round (Mid-Interview Change)
      • Day 9 — Ticket Booking with Expiry (Simulated Time)
      • Day 9 — Extension Round (Seat Lock Ownership + Forced Unlock)
    • SQL + DB Thinking course
      • Day 1 — Tables, Rows & Thinking in Data
      • Day 2 — Relationships & Foreign Keys (Thinking in Connections)
      • Day 3 — Filtering, Aggregation & Answering Data Questions
      • Day 4 — JOINs (Combining Tables the Right Way)
      • Day 5 — Subqueries, EXISTS & NOT EXISTS (Thinking in Layers)
      • Day 6 — Indexes, Constraints & How Databases Think
      • Day 7 — Full SQL Interview Simulation (SDE-1 Ready)
      • Extended Day 1 — Core Business Systems (Deep Practice)
      • Extended Day 2 — Booking & Platform Systems (High-Depth Practice)
      • Extended Day 3 — Content & Learning Platforms (Capstone Practice)
    • LLD: Java
      • DAY 1 — Core Foundations (SDE-2 Level)
      • DAY 2 — State, Time & Domain Correctness
      • DAY 3 — Extensibility & Failure Handling (SDE-2 Core Signal)
      • DAY 4 — Concurrency, Scheduling & Consistency (SDE-2 Critical)
      • DAY 5 — Workflow Design & Config-Driven Systems (SDE-2+)
      • DAY 6 — Eventing & Usage-Based Systems (Advanced SDE-2)
      • DAY 7 — Interview Simulation (Hard, Production-Grade)
      • Hidden Edge Cases Interviewers Expect (Day-wise)
      • Detailed Testing file:
    • Assignment:
      • If else Practice Set

Day 7: Parking lot System :

This day is designed to feel exactly like an SDE-1 machine coding round.
⏱ Time-bound
📄 Clear problem statement
🧱 Given structure & signatures
🧪 Deterministic tests
❌ No hints during coding
✅ Focus only on correct implementation

🟢 Day 7 — Full Machine Coding Simulation (SDE-1 Level)

🎯 Day 7 Objective

By the end of Day 7, the candidate should be able to:
Read a large problem statement
Identify required classes and responsibilities
Implement logic inside given method signatures
Handle multiple interacting objects
Respect constraints & state transitions
Pass all tests within 60–90 minutes
This day answers one question: ​“Can you clear a real machine coding round?”

⏱️ Interview Simulation Rules (IMPORTANT)

Give these rules to the candidate before starting:
⏰ Time limit: 90 minutes
❌ Do NOT change class names or method signatures
❌ Do NOT add new public methods
❌ Do NOT modify test file
✅ You may add private helpers if needed
✅ Return values exactly as specified
❌ No print statements in solution

🧩 The Problem — Parking Lot System (Simplified)

Problem Statement

You are implementing a Parking Lot system.
The system supports:
Multiple parking spots
Parking and un-parking vehicles
Tracking availability
This is a state-heavy, rule-heavy machine coding problem.

🚗 System Rules

Parking Spot States

Each parking spot can be:
FREE
OCCUPIED

Vehicle Rules

Each vehicle has a unique vehicle_id
One vehicle occupies one spot
Same vehicle cannot be parked twice

🧱 Class Definitions (DO NOT MODIFY)

class Vehicle:
def __init__(self, vehicle_id: str):
pass


class ParkingSpot:
def __init__(self, spot_id: int):
pass

def park(self, vehicle: Vehicle) -> bool:
pass

def unpark(self) -> bool:
pass

def is_free(self) -> bool:
pass

def get_vehicle(self):
pass


class ParkingLot:
def __init__(self, total_spots: int):
pass

def park_vehicle(self, vehicle: Vehicle) -> bool:
pass

def unpark_vehicle(self, vehicle_id: str) -> bool:
pass

def get_available_spots(self) -> int:
pass

📋 Detailed Requirements (READ CAREFULLY)

Vehicle

Store vehicle_id

ParkingSpot

Initial State
Spot is FREE
No vehicle assigned
park(vehicle)
If spot is already OCCUPIED → return False
Else:
Assign vehicle
Mark as OCCUPIED
Return True
unpark()
If spot is FREE → return False
Else:
Remove vehicle
Mark as FREE
Return True
is_free()
Return True if FREE, else False
get_vehicle()
Return vehicle object if OCCUPIED
Else return None

ParkingLot

__init__(total_spots)
Create total_spots ParkingSpot objects
Spot IDs should start from 1
park_vehicle(vehicle)
If vehicle already parked → return False
Find the first FREE spot
Park the vehicle
Return True if parked
If no free spot → return False
unpark_vehicle(vehicle_id)
Find spot containing this vehicle
If found:
Unpark it
Return True
If not found → return False
get_available_spots()
Return number of FREE spots

🧠 Expected Thinking Process (Not Code)

Candidate should think:
ParkingLot manages many ParkingSpots
ParkingSpot manages one Vehicle
Vehicle is a simple data object
State lives inside ParkingSpot
ParkingLot coordinates operations
Must prevent duplicate vehicle parking

🧪 (Given to Candidate)

class Vehicle:
def __init__(self, vehicle_id: str):
pass


class ParkingSpot:
def __init__(self, spot_id: int):
pass

def park(self, vehicle: Vehicle) -> bool:
pass

def unpark(self) -> bool:
pass

def is_free(self) -> bool:
pass

def get_vehicle(self):
pass


class ParkingLot:
def __init__(self, total_spots: int):
pass

def park_vehicle(self, vehicle: Vehicle) -> bool:
pass

def unpark_vehicle(self, vehicle_id: str) -> bool:
pass

def get_available_spots(self) -> int:
pass

🧪 test_day7.py (Evaluation File)

from solution import Vehicle, ParkingLot


def test_parking_lot_basic():
print("Running basic parking tests...")

lot = ParkingLot(2)

v1 = Vehicle("V1")
v2 = Vehicle("V2")
v3 = Vehicle("V3")

assert lot.get_available_spots() == 2

assert lot.park_vehicle(v1) is True
assert lot.get_available_spots() == 1

assert lot.park_vehicle(v2) is True
assert lot.get_available_spots() == 0

assert lot.park_vehicle(v3) is False # no space

print("✅ Basic parking tests passed")


def test_unpark():
print("Running unpark tests...")

lot = ParkingLot(2)
v1 = Vehicle("V1")
v2 = Vehicle("V2")

lot.park_vehicle(v1)
lot.park_vehicle(v2)

assert lot.unpark_vehicle("V1") is True
assert lot.get_available_spots() == 1

assert lot.unpark_vehicle("V1") is False # already removed
assert lot.unpark_vehicle("UNKNOWN") is False

print("✅ Unpark tests passed")


def test_duplicate_vehicle():
print("Running duplicate vehicle tests...")

lot = ParkingLot(2)
v1 = Vehicle("V1")

assert lot.park_vehicle(v1) is True
assert lot.park_vehicle(v1) is False # same vehicle again

print("✅ Duplicate vehicle tests passed")


if __name__ == "__main__":
test_parking_lot_basic()
test_unpark()
test_duplicate_vehicle()

print("\n🎉 ALL DAY 7 TESTS PASSED SUCCESSFULLY")

✅ Pass Criteria (Strict)

Candidate passes Day 7 if:
All tests pass
No modification to test file
No signature changes
No prints
No global state
Code runs in one go

🧠 Final Reflection (Must Answer)

How did you break down the problem?
 
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.