We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7a2ce85 commit 4f80bc1Copy full SHA for 4f80bc1
kojungbeom/Programmers/Level2/롤케이크 자르기.py
@@ -0,0 +1,26 @@
1
+def solution(topping):
2
+ answer = 0
3
+ cdict = {}
4
+ bdict = {}
5
+
6
+ for t in topping:
7
+ if t in bdict:
8
+ bdict[t] += 1
9
+ else:
10
+ bdict[t] = 1
11
12
13
+ bdict[t] -= 1
14
+ if bdict[t] == 0:
15
+ del bdict[t]
16
17
+ if t in cdict:
18
+ cdict[t] += 1
19
20
+ cdict[t] = 1
21
22
+ if len(bdict) == len(cdict):
23
+ answer += 1
24
+ elif len(bdict) < len(cdict):
25
+ break
26
+ return answer
0 commit comments