Skip to content

Commit 4f80bc1

Browse files
committed
[PGS] 롤케이크 자르기 / Level2 / 8분
1 parent 7a2ce85 commit 4f80bc1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
for t in topping:
13+
bdict[t] -= 1
14+
if bdict[t] == 0:
15+
del bdict[t]
16+
17+
if t in cdict:
18+
cdict[t] += 1
19+
else:
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

Comments
 (0)