[프로그래머스] 주식가격
·
Algorithm
문제 풀이 #1(이중 반복문 - O(n^2))def solution(prices): res = [] last_index = len(prices) - 1 #첫 인덱스부터 반복하며 비교 for i in range(len(prices)) : #마지막 인덱스일 경우, 0 추가 if i == last_index : res.append(0) break #현재 비교하는 인덱스부터 끝까지 비교 for j in range(i + 1, len(prices)) : if prices[i] > prices[j] : res.append(j - i) ..