Skip to content

Commit 1037a4c

Browse files
committed
내풀이
1 parent 42423db commit 1037a4c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

프로그래머스/1_체육복.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def solution(n, lost, reserve):
2+
def bollow(array, x):
3+
if array[x] != 0:
4+
array[x] = 0
5+
return True
6+
else : False
7+
8+
#도난당한 친구들만큼 빼주기
9+
answer = n-len(lost)
10+
chk = [0] * (n+1)
11+
12+
#여벌 체육복 가져온 친구들 reserver
13+
for num in reserve:
14+
chk[num] += 1
15+
16+
17+
for i in range(1, n+1) :
18+
if i in lost :
19+
if bollow(chk, i-1) or bollow(chk, i+1):
20+
answer +=1
21+
22+
return answer

0 commit comments

Comments
 (0)