> 알고리즘 문제 풀이/프로그래머스27 20/09- 다리를 지나는 트럭 def solution(bridge_length, weight, truck_weights): answer = 0 bridge_on = [0] * bridge_length curr_weight = 0 while truck_weights: answer += 1 bridge_out = bridge_on.pop(0) curr_weight -= bridge_out if curr_weight + truck_weights[0] > weight: bridge_on.append(0) else: truck = truck_weights.pop(0) bridge_on.append(truck) curr_weight += truck while curr_weight>0: answer += 1 bridge_out = bridge_o.. 2020. 9. 28. 20/09 - 기능개발 def solution(progresses, speeds): answer = [] days = [0] * len(progresses) for x in range(len(progresses)): days[x] = (100 - progresses[x]) / speeds[x] if (100 - progresses[x]) % speeds[x] != 0: days[x] += 1 while len(days) >= 2: day = days.pop(0) completed = 1 if day >= days[0]: while len(days) >= 1 and day >= days[0]: days.pop(0) completed += 1 answer.append(completed) if len(days) == 1: answe.. 2020. 9. 21. 20/09 - 주식가격 from collections import deque def solution(prices): prices_dq = deque(prices) answer = [0]*len(prices) if len(prices_dq) == 2: return [1,0] for x in range(len(prices_dq)): current_price = prices_dq.popleft() for next_price in prices_dq: answer[x] += 1 if current_price > next_price: break return answer print(solution([1, 2, 3, 2, 3])) """ [4, 3, 1, 1, 0] """ """ prices = ABCD A를 pop한다 prices = BC.. 2020. 9. 20. 이전 1 ··· 4 5 6 7 다음