Skip to content

Commit

Permalink
2024-04-05 오큰수
Browse files Browse the repository at this point in the history
  • Loading branch information
seongwon030 committed Apr 5, 2024
1 parent 66184fa commit ceb3d19
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions seongwon030/스택/오큰수.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
n = int(input())
A = list(map(int,input().split()))
NGE = [-1]*n
stack = [0]

for i in range(1,n):
while stack and A[stack[-1]] < A[i]:
NGE[stack.pop()] = A[i]
stack.append(i)
print(*NGE)

0 comments on commit ceb3d19

Please sign in to comment.