Maximum Number of Balloons LeetCode solution in Python

1
class Solution:
2
def maxNumberOfBalloons(self, text: str) -> int:
3
freq = {"b": 0, "a": 0, "l": 0, "o": 0, "n": 0}
4

5
for char in text:
6
if not char in freq:
7
continue
8

9
step = 0.5 if char == "l" or char == "o" else 1
10

11
freq[char] += step
12

13
result = min(freq.values())
14

15
return floor(result)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0