탑
Updated:
- 프로그래머스 level_2
단순구현
입력값 〉 [1, 5, 3, 6, 7, 6, 5]
기댓값 〉 [0, 0, 2, 0, 0, 5, 6]
def solution(heights):
answer = []
answer.append(0)
for i in range(1,len(heights)):
check = False
for j in range(i-1,-1,-1):
if heights[j]>heights[i]:
answer.append(j+1)
check = True
break
if not check:
answer.append(0)
print(answer)
return answer
Leave a comment