Skip to content

Commit a8565d7

Browse files
authored
Create Day-13_Maximum_number_of_balloons.py
1 parent d901005 commit a8565d7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def maxNumberOfBalloons(self, text: str) -> int:
3+
s = set('balloon')
4+
d = {}
5+
6+
for i in text:
7+
d[i] = d.get(i,0) + 1
8+
9+
#print(d)
10+
ans = 0
11+
while True:
12+
for i in 'balloon':
13+
if i not in d or d[i] < 1:
14+
return ans
15+
else:
16+
d[i] -= 1
17+
ans += 1
18+
19+
20+
return ans

0 commit comments

Comments
 (0)