Skip to content

Commit

Permalink
2024.02.23 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
JangHongJoon committed Feb 24, 2024
1 parent a62c3e7 commit 075829a
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions wkdghdwns199/μŠ€ν…_큐_덱/ACM-12789.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
order = 1
stack = []

for student in order_list :
if student > order :
stack.append(student)
elif student == order :
order+=1
# 5 4 2 3 1

while len(stack) !=0 :
if len(stack) == 1 or stack[len(stack)-2] > stack[len(stack)-1] :
stack.pop()
else : break
while order_list :
if order_list[0] == order:
order_list.pop(0)
order+=1
else :
stack.append(order_list.pop(0))

while stack :
if stack[-1] == order:
stack.pop()
order +=1
else :
break


print('Nice') if len(stack)==0 else print('Sad')

0 comments on commit 075829a

Please sign in to comment.