일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- Substring with Concatenation of All Words
- 30. Substring with Concatenation of All Words
- 43. Multiply Strings
- Convert Sorted List to Binary Search Tree
- 운영체제
- Protocol
- t1
- LeetCode
- Decorator
- Regular Expression
- 밴픽
- DWG
- data science
- 프로그래머스
- shiba
- Python Implementation
- 715. Range Module
- Python
- 컴퓨터의 구조
- Generator
- concurrency
- attribute
- iterator
- Python Code
- 315. Count of Smaller Numbers After Self
- kaggle
- Class
- 시바견
- 파이썬
- 109. Convert Sorted List to Binary Search Tree
Archives
- Today
- Total
Scribbling
프로그래머스: 구명보트 본문
몸무게로 줄을 세우고, 돼지와 홀쭉이를 매칭시켜준다.
def solution(people, limit):
answer = 0
people.sort(reverse=True)
i, j = 0, len(people) - 1
while i <= j:
if people[i] + people[j] <= limit:
answer += 1
i += 1
j -= 1
else:
answer += 1
i +=1
return answer
'Computer Science > Coding Test' 카테고리의 다른 글
프로그래머스: 단속카메라 (0) | 2021.10.21 |
---|---|
프로그래머스: 섬 연결하기 (0) | 2021.10.21 |
프로그래머스: 큰 수 만들기 (0) | 2021.10.20 |
LeetCode: 105. Construct Binary Tree from Preorder and Inorder Traversal (0) | 2021.10.20 |
LeetCode: 103. Binary Tree Zigzag Level Order Traversal (0) | 2021.10.20 |