Programing/자료구조, Algorithm
programmers - 탑[level2] - python
r00t0k
2019. 1. 24. 00:47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | def solution(heights): answer = [0] tmp = [] for i in range(len(heights)-1, 0, -1): # 역순 for j in range(i-1, -1, -1): if heights[i] < heights[j]: tmp.append(j+1) break elif j == 0: tmp.append(0) for i in reversed(tmp): answer.append(i) return answer | cs |