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)
      • Day 7: Parking lot System :
    • Machine coding extended:
      • icon picker
        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.5 — Parking Lot (Constraint-Heavy Variant)

Perfect. Below is Day 7.5 — Extended Machine Coding (Level-1+) in the same strict, interview-ready format.
This day is intentionally harder than Day 7, but still safe for SDE-1. No new concepts — just more constraints + deeper thinking.

🟢 Day 7.5 — Parking Lot (Constraint-Heavy Variant)

This is the bridge between “I can code” and “I can handle real machine-coding interviews.”

🎯 Day 7.5 Objective

By the end of Day 7.5, the candidate should be able to:
Extend an existing system with additional constraints
Handle compatibility rules
Implement conditional object matching
Maintain correctness under more rules
Still pass tests without redesigning everything
This day tests discipline, not intelligence.

⏱ Interview Simulation Rules

Give these to the candidate before starting:
⏰ Time limit: 75 minutes
❌ Do NOT change class names
❌ Do NOT change method signatures
❌ Do NOT modify test file
❌ No print statements
✅ Use only given structure
✅ Return values exactly as required

🧠 What’s New Compared to Day 7?

Day 7
Day 7.5
Single vehicle type
Multiple vehicle types
Any spot works
Spot–vehicle compatibility
Simple rules
More validation
Same structure
Same structure + more logic
There are no rows in this table
⚠️ No new abstractions allowed

🚗 Problem — Parking Lot with Vehicle & Spot Types

📋 System Rules (Read Carefully)

Vehicle Types

CAR
BIKE
Each vehicle has:
vehicle_id
vehicle_type

Parking Spot Types

CAR_ONLY
BIKE_ONLY
ANY
Each spot can park:
CAR_ONLY → only CAR
BIKE_ONLY → only BIKE
ANY → both

Parking Rules

One vehicle → one spot
Vehicle cannot be parked twice
Spot can hold only one vehicle
Vehicle must be compatible with spot type
ParkingLot assigns first available compatible spot

🧱 Class Definitions (DO NOT MODIFY)

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


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

def can_park(self, vehicle: Vehicle) -> bool:
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, spots: list):
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 (NO GUESSING)

Vehicle

__init__
Store:
vehicle_id
vehicle_type

ParkingSpot

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

ParkingLot

__init__(spots)
spots is a list of ParkingSpot objects
ParkingLot does NOT create spots
It only manages them
park_vehicle(vehicle)
If vehicle already parked anywhere → return False
Find first FREE & compatible spot
Park vehicle there
Return True
If no such spot → return False
unpark_vehicle(vehicle_id)
Find spot with this vehicle
If found:
Unpark
Return True
Else → return False
get_available_spots()
Return count of FREE spots

🧠 Expected Thinking Process

Candidate should realize:
ParkingLot coordinates
ParkingSpot enforces compatibility
Vehicle is just data
No spot scanning shortcuts
Validation happens before mutation

🧪 (Given to Candidate)

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


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

def can_park(self, vehicle: Vehicle) -> bool:
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, spots: list):
pass

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

def unpark_vehicle(self, vehicle_id: str) -> bool:
 
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.