일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- Class
- 프로그래머스
- Python Code
- LeetCode
- 109. Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- 715. Range Module
- t1
- iterator
- 밴픽
- shiba
- 시바견
- Protocol
- Generator
- DWG
- kaggle
- data science
- 컴퓨터의 구조
- attribute
- Convert Sorted List to Binary Search Tree
- 43. Multiply Strings
- Python
- Python Implementation
- concurrency
- Regular Expression
- 파이썬
- 운영체제
- Decorator
Archives
- Today
- Total
Scribbling
프로그래머스: 다리를 지나는 트럭 본문
from collections import deque
def solution(bridge_length, weight, truck_weights):
time, total_weight = 1, 0
q = deque()
truck_weights = deque(truck_weights)
while truck_weights:
if not q:
w = truck_weights.popleft()
q.append([time, w])
total_weight += w
else:
if q[0][0] + bridge_length == time:
total_weight -= q[0][1]
q.popleft()
w = truck_weights[0]
if total_weight + w <= weight:
w = truck_weights.popleft()
q.append([time, w])
total_weight += w
time += 1
return q[-1][0] + bridge_length
'Computer Science > Coding Test' 카테고리의 다른 글
프로그래머스: 더 맵게 (0) | 2021.10.16 |
---|---|
프로그래머스: 주식 가격 (0) | 2021.10.16 |
LeetCode: 96. Unique Binary Search Trees (0) | 2021.10.13 |
LeetCode: 95. Unique Binary Search Trees II (0) | 2021.10.13 |
LeetCode: 92. Reverse Linked List II (0) | 2021.10.12 |