< Summary

Information
Class: LeetCode.Algorithms.DesignParkingSystem.DesignParkingSystemCounting
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\DesignParkingSystem\DesignParkingSystemCounting.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 73
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
AddCar(...)100%1010100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\DesignParkingSystem\DesignParkingSystemCounting.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2026 Eugene Eremeev (also known as Yevhenii Yeriemeieiv).
 3// All Rights Reserved.
 4// --------------------------------------------------------------------------------
 5// This software is the confidential and proprietary information of Eugene Eremeev
 6// (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not
 7// disclose such Confidential Information and shall use it only in accordance with
 8// the terms of the license agreement you entered into with Eugene Eremeev (also
 9// known as Yevhenii Yeriemeieiv).
 10// --------------------------------------------------------------------------------
 11
 12namespace LeetCode.Algorithms.DesignParkingSystem;
 13
 14/// <inheritdoc />
 15public sealed class DesignParkingSystemCounting : IDesignParkingSystem
 16{
 17    private readonly int _bigCapacity;
 18    private readonly int _mediumCapacity;
 19    private readonly int _smallCapacity;
 20    private int _bigCount;
 21    private int _mediumCount;
 22    private int _smallCount;
 23
 24    /// <summary>
 25    ///     Time complexity - O(1)
 26    ///     Space complexity - O(1)
 27    /// </summary>
 28    /// <param name="bigCapacity"></param>
 29    /// <param name="mediumCapacity"></param>
 30    /// <param name="smallCapacity"></param>
 1131    public DesignParkingSystemCounting(int bigCapacity, int mediumCapacity, int smallCapacity)
 1132    {
 1133        _bigCapacity = bigCapacity;
 1134        _mediumCapacity = mediumCapacity;
 1135        _smallCapacity = smallCapacity;
 1136    }
 37
 38    /// <summary>
 39    ///     Time complexity - O(1)
 40    ///     Space complexity - O(1)
 41    /// </summary>
 42    /// <param name="carType"></param>
 43    /// <returns></returns>
 44    public bool AddCar(int carType)
 3745    {
 3746        switch (carType)
 47        {
 1348            case 1 when _bigCount == _bigCapacity:
 49
 450                return false;
 51            case 1:
 952                _bigCount++;
 53
 954                return true;
 1255            case 2 when _mediumCount == _mediumCapacity:
 56
 357                return false;
 58            case 2:
 959                _mediumCount++;
 60
 961                return true;
 1162            case 3 when _smallCount == _smallCapacity:
 63
 264                return false;
 65            case 3:
 966                _smallCount++;
 67
 968                return true;
 69            default:
 170                return false;
 71        }
 3772    }
 73}