반응형
#### 시간 초과 나오는 코드####
def solution(prices):
answer =[]
temp_prices = []
while True:
if len(prices) == 0:
break
temp_prices.append(prices.pop(0))
value = [i for i in prices if i < temp_prices[0]]
#print("temp prices : {}".format(temp_prices))
#print("value : {}".format(value))
#print("prices : {}".format(prices))
#print(value)
if len(value) == 0:
answer.append(len(prices))
else:
#print(value)
output = value.pop(0)
#print("output : {}".format(output))
answer.append( (prices.index(output)+1) )
temp_prices.pop(0)
#print(answer)
return answer
반응형
'IT 인터넷 > 프로그래머스' 카테고리의 다른 글
(작성중)프로그래머스 (해시) 베스트엘범 - Python3 (0) | 2022.03.10 |
---|---|
프로그래머스 (해시) 위장 -Python3 파이썬 (0) | 2022.03.10 |
프로그래머스 (해시) 전화번호 목록 - Python3 파이썬 (0) | 2022.03.09 |
프로그래머스 (스택/큐) 다리를 지나는 트럭 - Python3 파이썬 (0) | 2022.03.08 |
프로그래머스 (스택 & 큐) 프린터 - Python3 (0) | 2022.03.07 |