| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 시바견
- attribute
- Python Code
- t1
- LeetCode
- Python
- 109. Convert Sorted List to Binary Search Tree
- data science
- 43. Multiply Strings
- 운영체제
- 프로그래머스
- 315. Count of Smaller Numbers After Self
- 컴퓨터의 구조
- Regular Expression
- 밴픽
- DWG
- Substring with Concatenation of All Words
- 파이썬
- Class
- iterator
- 715. Range Module
- concurrency
- Convert Sorted List to Binary Search Tree
- Decorator
- Generator
- shiba
- 30. Substring with Concatenation of All Words
- Protocol
- Python Implementation
- kaggle
Archives
- Today
- Total
Scribbling
LeetCode: 198. House Robber 본문
DP 기초 문제로 맨날 보는 문제
class Solution:
def rob(self, nums: List[int]) -> int:
if len(nums) <= 2:
return max(nums)
dp = [0] * len(nums)
dp[0] = nums[0]
dp[1] = max(nums[0], nums[1])
for i in range(2, len(nums)):
dp[i] = max(dp[i-2]+nums[i], dp[i-1])
return dp[len(nums)-1]'Computer Science > Coding Test' 카테고리의 다른 글
| LeetCode: 1011. Capacity To Ship Packages Within D Days (0) | 2021.12.06 |
|---|---|
| LeetCode: 204. Count Primes (0) | 2021.12.05 |
| LeetCode: 179. Largest Number (0) | 2021.12.04 |
| LeetCode: 172. Factorial Trailing Zeroes (0) | 2021.12.04 |
| LeetCode: 160. Intersection of Two Linked Lists (0) | 2021.12.02 |