Skip to content

Commit 80af907

Browse files
author
hangyeol
committed
105차 3번 문제 풀이
1 parent f1c2bd6 commit 80af907

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def solution(order):
2+
index = 0
3+
stack = []
4+
truck = []
5+
6+
for i in range(1, len(order) + 1):
7+
if i == order[index]:
8+
truck.append(i)
9+
index += 1
10+
else:
11+
stack.append(i)
12+
13+
while stack and stack[-1] == order[index]:
14+
truck.append(stack.pop())
15+
index += 1
16+
17+
return len(truck)

0 commit comments

Comments
 (0)