1297. Maximum Number of Balloons
My accepted Python solution to LeetCode problem 1297, Maximum Number of Balloons, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.4MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.4MB, accepted 2025-12-30.
class Solution:
def maxNumberOfBalloons(self, text: str) -> int:
from collections import Counter
count = Counter(text)
# balloon needs: b=1, a=1, l=2, o=2, n=1
return min(
count['b'],
count['a'],
count['l'] // 2,
count['o'] // 2,
count['n']
)