https://programmers.co.kr/learn/courses/30/lessons/42584
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
def solution(prices):
answer = []
n = len(prices)
for i in range(n):
pivot = prices[i]
for j in range(i, n):
if prices[j] < pivot:
answer.append(j-i)
break
else:
answer.append((n-1)-i)
return answer
Complexity
$O(n^2)$
- $n$ = len(prices)
PREVIOUSEtc