[코테 풀이] Design Parking System

시내·2024년 6월 10일
0

Q_1603) Design Parking System

출처 : https://leetcode.com/problems/design-parking-system/

class ParkingSystem {
    int[] n;

    public ParkingSystem(int big, int medium, int small) {
        n = new int[]{big, medium, small};
    }

    public boolean addCar(int carType) {
        if (n[carType - 1] > 0) {
            n[carType - 1]--;
            return true;
        }
        return false;
    }
}

/**
 * Your ParkingSystem object will be instantiated and called as such:
 * ParkingSystem obj = new ParkingSystem(big, medium, small);
 * boolean param_1 = obj.addCar(carType);
 */
profile
contact 📨 ksw08215@gmail.com

0개의 댓글