Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Design/1603. Design Parking System.py

This file was deleted.

Empty file.
13 changes: 13 additions & 0 deletions problems/easy/design_parking_system_1603/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tags: Design, Simulation, Counting
class ParkingSystem:

def __init__(self, big: int, medium: int, small: int):
self.spaces = {1: big,
2: medium,
3: small}
Comment on lines +5 to +7
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dictionary formatting is inconsistent with PEP 8 style for multiline dictionaries. When a dictionary is split across multiple lines, each key-value pair should be on its own line with consistent indentation, or the opening brace should be followed by a newline. Consider formatting as either: self.spaces = {1: big, 2: medium, 3: small} (single line) or with proper alignment:

self.spaces = {
    1: big,
    2: medium,
    3: small
}
Suggested change
self.spaces = {1: big,
2: medium,
3: small}
self.spaces = {
1: big,
2: medium,
3: small
}

Copilot uses AI. Check for mistakes.

def add_car(self, car_type: int) -> bool:
if self.spaces[car_type] == 0:
return False
self.spaces[car_type] -= 1
return True
Comment on lines +9 to +13
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The add_car method doesn't validate that car_type is valid (1, 2, or 3). If an invalid car_type is passed, this will raise a KeyError when accessing self.spaces[car_type]. While LeetCode constraints may guarantee valid inputs, defensive programming suggests adding validation or at least a comment about the expected input range. Consider adding a check or documenting the assumption that car_type will always be in range [1, 3].

Copilot uses AI. Check for mistakes.
36 changes: 36 additions & 0 deletions problems/easy/design_parking_system_1603/test_solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from .solution import ParkingSystem


class TestSolution:

Comment on lines +2 to +5
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TestSolution class doesn't inherit from BaseTestSolution, which is the common pattern for most test files in the codebase. While not strictly required for this simple test, inheriting from BaseTestSolution provides consistency with other tests and access to utilities like timeout handling. Consider changing to "class TestSolution(BaseTestSolution):" and adding the import "from tests.base_test import BaseTestSolution".

Suggested change
class TestSolution:
from tests.base_test import BaseTestSolution
class TestSolution(BaseTestSolution):

Copilot uses AI. Check for mistakes.
def call(self, methods, params, expected):
results = []
obj = None
for method, param in zip(methods, params):
if method == "ParkingSystem":
obj = ParkingSystem(*param)
results.append(None)
else:
result = getattr(obj, method)(*param)
results.append(result)
assert results == expected

def test_example_1(self):
"""
Example 1:
Input: ["ParkingSystem", "add_car", "add_car", "add_car", "add_car"]
[[1, 1, 0], [1], [2], [3], [1]]
Output: [null, true, true, false, false]

Explanation:
ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);
parkingSystem.add_car(1); // return true because there is 1 available slot for a big car
parkingSystem.add_car(2); // return true because there is 1 available slot for a medium car
parkingSystem.add_car(3); // return false because there is no available slot for a small car
parkingSystem.add_car(1); // return false because there is no available slot for a big car. It is already occupied.
"""
self.call(
["ParkingSystem", "add_car", "add_car", "add_car", "add_car"],
[[1, 1, 0], [1], [2], [3], [1]],
[None, True, True, False, False],
)