This commit is contained in:
parent
b402cce21a
commit
0e68584bea
1 changed files with 21 additions and 0 deletions
21
easy/maximum_number_of_ballons.py
Normal file
21
easy/maximum_number_of_ballons.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# https://leetcode.com/problems/maximum-number-of-balloons
|
||||
|
||||
class Solution:
|
||||
def maxNumberOfBalloons(self, text: str) -> int:
|
||||
b = 0
|
||||
a = 0
|
||||
l = 0
|
||||
o = 0
|
||||
n = 0
|
||||
for char in text:
|
||||
if char == 'b':
|
||||
b += 1
|
||||
elif char == 'a':
|
||||
a += 1
|
||||
elif char == 'l':
|
||||
l += 1
|
||||
elif char == 'o':
|
||||
o += 1
|
||||
elif char == 'n':
|
||||
n += 1
|
||||
return min(b, a, l // 2, o // 2, n)
|
||||
Loading…
Add table
Add a link
Reference in a new issue