[Python] 프로그래머스 / 스택/큐 / 주식가격 / 리스트 숫자 비교

2024. 3. 9. 08:41Coding Test/Python

문제 이해 : 

https://school.programmers.co.kr/questions/20326?question=20326

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

def solution(prices):
    answer = []
    for i in range(len(prices)):
        time = 0
        for j in range(i+1, len(prices)):
            time += 1
            if prices[j]<prices[i]:
                break
        answer.append(time)
    return answer

 

유일하게 stack을 쓰지 않고 풀었는 문제!