
【python】Leetcode每日一题-设计停车系统
发布日期:2021-05-11 06:28:16
浏览次数:8
分类:博客文章
本文共 2036 字,大约阅读时间需要 6 分钟。
���python���Leetcode������������-������������������
������������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������ ParkingSystem
������
ParkingSystem(int big, int medium, int small)
��������� ParkingSystem
���������������������������������������������������������bool
addCar(int carType)
��������������� carType
��������������������� carType
��������������������������������������������������� 1��� 2
��� 3
������������������������������ carType
��������������������������������������������������������������� false ��������������������������������������� true
���
������1���
���������["ParkingSystem", "addCar", "addCar", "addCar", "addCar"][[1, 1, 0], [1], [2], [3], [1]]���������[null, true, true, false, false]���������ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);parkingSystem.addCar(1); // ������ true ������������ 1 ������������������parkingSystem.addCar(2); // ������ true ������������ 1 ������������������parkingSystem.addCar(3); // ������ false ������������������������������parkingSystem.addCar(1); // ������ false ������������������������������������������������������������������������
���������
0 <= big, medium, small <= 1000carType ��������� 1��� 2 ��� 3��������������� addCar ������ 1000 ���
������������
���������������
AC���������
class ParkingSystem(object): def __init__(self, big, medium, small): """ :type big: int :type medium: int :type small: int """ self.big = big self.medium = medium self.small = small def addCar(self, carType): """ :type carType: int :rtype: bool """ if(self.big > 0 and carType == 1): self.big -= 1 return True elif(self.medium > 0 and carType == 2): self.medium -= 1 return True elif(self.small > 0 and carType == 3): self.small -= 1 return True return False
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2025年04月11日 01时38分50秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
(ಥ_ಥ) VMware中安装Centos
2021-05-11
**精准实时采集数据是什么???
2021-05-11
软考需要报班学习吗?
2021-05-11
基于VS的连连看小游戏
2021-05-11
map[]和map.at()取值之间的区别
2021-05-11
成功解决升级virtualenv报错问题
2021-05-11
iOS KVC
2021-05-11
CoreText(四):行 CTLineRef
2021-05-11
iOS 8:一、tableView右滑显示选择
2021-05-11
解决hadoop出现Warning: fs.defaultFS is not set异常
2021-05-11
Android开发之获取常用android设备参数信息
2021-05-11
Jenkins打包之本地远程自动打包教程
2021-05-11
【SQLI-Lab】靶场搭建
2021-05-11
java——如何停止一个线程
2021-05-11
linux环境下nginx安装
2021-05-11
mysql 分区-range分区(二)
2021-05-11
Xception 设计进化
2021-05-11
shell基础---行转列(awk),列转行(tr)
2021-05-11
抗DDOS攻击
2021-05-11