문제 링크: https://www.acmicpc.net/problem/17298
백준 알고리즘 기초 1/2 201에서 3번째 - 17298번 오큰수를 풀어보았다.
풀이: https://wiselog.tistory.com/111 이 코드를 참고했다.
파이썬은 리스트를 출력할 때 *를 붙이면 된다는 것을 알게 되었다.
C++
Python
n=int(input())
inp=list(map(int,input().split()))
stack=[]
res=[-1 for i in range(n)]
for i in range(n):
while stack and inp[stack[-1]]<inp[i]:
res[stack.pop()]=inp[i]
stack.append(i)
print(*res)
Java
'코테용 문제풀이 > 백준' 카테고리의 다른 글
후위 표기식2 풀이 (0) | 2023.01.10 |
---|---|
오등큰수 풀이 (0) | 2023.01.10 |
쇠막대기 풀이 (0) | 2023.01.10 |
단어 뒤집기 2 풀이 (0) | 2023.01.10 |
덱 풀이 (0) | 2023.01.10 |