일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 715. Range Module
- iterator
- Convert Sorted List to Binary Search Tree
- Python Code
- Class
- data science
- LeetCode
- 프로그래머스
- 시바견
- Python
- shiba
- Generator
- DWG
- Decorator
- 컴퓨터의 구조
- 43. Multiply Strings
- Substring with Concatenation of All Words
- Regular Expression
- Python Implementation
- concurrency
- t1
- 315. Count of Smaller Numbers After Self
- attribute
- 밴픽
- 30. Substring with Concatenation of All Words
- kaggle
- 운영체제
- 109. Convert Sorted List to Binary Search Tree
- 파이썬
- Protocol
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 |