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