Skip to content

Commit b32da52

Browse files
committed
change solution according to neetcode video
1 parent ded55a4 commit b32da52

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python/1189-Maximum-Number-of-Balloons.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33

44
class Solution:
55
def maxNumberOfBalloons(self, text: str) -> int:
6-
count = Counter(text)
7-
return min(count["b"], count["a"], count["l"] >> 1, count["o"] >> 1, count["n"])
6+
countText = Counter(text)
7+
balloon = Counter("balloon")
8+
9+
res = len(text) # or float("inf")
10+
for c in balloon:
11+
res = min(res, countText[c] // balloon[c])
12+
return res

0 commit comments

Comments
 (0)