Skip to content

Commit 1c473b2

Browse files
committed
24_kakao_가장 많이 받은 선물
1 parent af2db99 commit 1c473b2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def solution(friends, gifts):
2+
score = {name: {friend: 0 for friend in friends} for name in friends}
3+
4+
for gift in gifts:
5+
p, d = gift.split()
6+
7+
score[p][p] += 1
8+
score[d][d] -= 1
9+
10+
score[p][d] += 1
11+
score[d][p] -= 1
12+
13+
gift = {name: 0 for name in friends}
14+
15+
for order, fre in score.items():
16+
cnt = 0
17+
for k, v in fre.items():
18+
if v > 0 and order != k:
19+
cnt += 1
20+
elif v == 0 and (score[k][k] < score[order][order]) and order != k:
21+
cnt += 1
22+
gift[order] = cnt
23+
24+
return max(gift.values())

0 commit comments

Comments
 (0)