3168. Minimum Number of Chairs in a Waiting Room
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 78% Topics: String, Simulation
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
# simulation
class Solution(object):
def minimumChairs(self, s):
"""
:type s: str
:rtype: int
"""
result = curr = 0
for x in s:
curr += +1 if x == "E" else -1
result = max(result, curr)
return result
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions