반응형

 


#### 시간 초과  나오는 코드####

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
반응형

+ Recent posts