Bird
0
0
LLDsystem_design~20 mins

Enum usage (VehicleType, SpotType) in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Enum Mastery in Parking System
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Enum Role in Parking Lot Design

In a parking lot system, VehicleType and SpotType enums are used. What is the main purpose of using enums here?

ATo restrict vehicle and spot categories to predefined constant values for clarity and safety.
BTo allow dynamic creation of vehicle and spot types at runtime.
CTo store vehicle and spot data in a database table.
DTo randomly assign vehicle types to spots.
Attempts:
2 left
💡 Hint

Think about how enums help avoid errors by limiting options.

Architecture
intermediate
1:30remaining
Mapping VehicleType to SpotType in Design

Which design best represents the relationship between VehicleType and SpotType enums in a parking lot system?

AEach VehicleType maps to one or more compatible SpotTypes to check parking eligibility.
BSpotType values are randomly assigned to VehicleType values without mapping.
CVehicleType and SpotType enums are merged into a single enum for simplicity.
DVehicleType enum contains SpotType values as its members.
Attempts:
2 left
💡 Hint

Consider how the system knows which vehicle fits which spot.

scaling
advanced
2:00remaining
Scaling Enum Usage for New Vehicle and Spot Types

When adding new vehicle and spot types frequently, what is the best approach to keep the enum usage scalable and maintainable?

ACreate a separate enum for each new vehicle and spot type pair.
BHardcode all new types directly into enums and recompile the system each time.
CRemove enums and use plain strings everywhere for flexibility.
DUse enums with extension mechanisms or configuration files to add new types without code changes.
Attempts:
2 left
💡 Hint

Think about how to avoid frequent code changes for new types.

tradeoff
advanced
2:00remaining
Tradeoffs Between Enum and Database Lookup for SpotType

What is a key tradeoff when choosing between using enums or a database table to represent SpotType in a parking system?

AEnums are slower to access than database queries.
BDatabase tables cannot represent SpotType relationships.
CEnums offer compile-time safety but less flexibility; database allows dynamic updates but adds latency.
DEnums require a database connection to function.
Attempts:
2 left
💡 Hint

Consider flexibility versus performance and safety.

estimation
expert
2:30remaining
Estimating Capacity for Enum-Based Parking Spot Allocation

A parking system uses enums for VehicleType and SpotType. Given 3 VehicleTypes and 4 SpotTypes, with each VehicleType compatible with 2 SpotTypes, estimate the minimum number of spot instances needed to support 100 vehicles simultaneously, assuming uniform distribution and no sharing.

AAt least 150 spots, assuming some spot types can serve multiple vehicle types.
BExactly 100 spots, one per vehicle regardless of type.
CAt least 200 spots, because each vehicle needs a unique compatible spot.
DAt least 300 spots, to cover all combinations of vehicle and spot types.
Attempts:
2 left
💡 Hint

Think about how many spots are needed if each vehicle must have a compatible spot without sharing.