Skip to content

Commit 0e00f47

Browse files
authored
Create houe-robber.py
uses dynamic programming to find optimal solution
1 parent c381403 commit 0e00f47

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

houe-robber.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution(object):
2+
def rob(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: int
6+
"""
7+
l = 0
8+
r = 0
9+
for num in nums:
10+
temp = l
11+
l = max(num + r,l)
12+
r = temp
13+
return l

0 commit comments

Comments
 (0)