STUDY/Algorithm

[프로그래머스] LEVEL2 탑, python3, 스택/큐

sinawi95 2019. 10. 29. 12:25
728x90

from collections import deque
def solution(heights):
    answer = []
    heights=deque(heights)
    len_h=len(heights)
    for i in range(len_h):
        tmp=heights.pop()
        cnt=0
        ind=0
        for j in heights:
            cnt+=1
            if tmp:                ind=cnt
        answer.insert(0,ind)
    
    return answer