상세 컨텐츠

본문 제목

[프로그래머스 코딩테스트 고득점 kit] 주식가격 queue로 풀기

Python

by yukmim 2022. 1. 15. 19:42

본문

from collections import deque
def solution(prices):
    
    answer = []
    prices = deque(prices)
    
    while prices:
        value = 0
        standard = prices.popleft()
        for i in prices:
            if standard > i:
                value += 1
                break
            value += 1
        
        answer.append(value)
    
    return answer

관련글 더보기

댓글 영역