Algorithm

[1028알고리즘 13]탑송신

#[6, 9, 5, 7, 4]   →[0, 0, 2, 2, 4]
# 4 는 4번째에서 수신
# 7은 2번째에서 수신
# 5는 두번째에서 수신
# 9는 수신안됨
# 6은 수신안됨

top_heights = [6, 9, 5, 7, 4]


def get_resive_top_order(heights):
    result = [0]* len(heights)
    while heights:
        height = heights.pop()
        for idx in range(len(heights)-1,0,-1):
            print(idx)
            if heights[idx] > height:
                result[len(heights)] = idx +1
                break
    return result

print(get_resive_top_order(top_heights))

'Algorithm' 카테고리의 다른 글

[1028알고리즘 15]트리, 힙  (0) 2021.04.10
[1028알고리즘 14]그래프  (0) 2021.04.10
[1028알고리즘]Queue - JAVA  (0) 2021.04.10
[1028알고리즘 12] 큐 구현  (0) 2021.04.10
[1028알고리즘 11] 스택구현  (0) 2021.04.10