题目链接 | 3168. 候诊室中的最少椅子数 |
---|---|
思路 | 简单模拟 |
题解链接 | Wiki |
关键点 | 无 |
时间复杂度 | \(O(n)\) |
空间复杂度 | \(O(1)\) |
代码实现:
class Solution:
def minimumChairs(self, s: str) -> int:
answer = 0
remain = 0
for ch in s:
if ch == "E":
if remain:
remain -= 1
else:
answer += 1
else:
remain += 1
return answer
标签:ch,候诊室,复杂度,remain,最少,3168,answer
From: https://www.cnblogs.com/WrRan/p/18429120