Back to DSA sheet

Design Parking System

EasyArrays

A parking lot has a fixed number of big, medium, and small spots. Each car has a type (1 big, 2 medium, 3 small) and may park only in a spot of its own size. addCar returns true and parks the car if a matching spot is free, otherwise false.

Input format (stdin): the first line has big medium small. The second line has q (number of cars). Each next line has a car type (1, 2, or 3). Output true or false for each car, one per line.

Examples
Input: 1 1 0 4 1 2 3 1
Output: true true false false
The big and medium cars park; the small car has no spot; the second big car finds the only big spot taken.
Constraints
  • 0 <= big, medium, small <= 1000
  • carType in {1, 2, 3}
Sheets
NeetCode 250
design-parking-system.cpp1 sample tests
Loading editor
Test results

Run the sample tests to check your solution against expected output.

Custom input (stdin)
Output

Run your code to see its output.