Skip to content

Commit 0c41ad3

Browse files
author
Jinbeom
committed
House Robber Solution
1 parent 68d542c commit 0c41ad3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

house-robber/kayden.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
# 시간복잡도: O(N)
3+
# 공간복잡도: O(1)
4+
def rob(self, nums: List[int]) -> int:
5+
one, two = 0, 0
6+
7+
for num in nums:
8+
temp = max(two+num, one)
9+
two, one = one, temp
10+
11+
return one

0 commit comments

Comments
 (0)