Skip to content

Commit

Permalink
Create houe-robber.py
Browse files Browse the repository at this point in the history
uses dynamic programming to find optimal solution
  • Loading branch information
gabedonnan authored Jan 12, 2023
1 parent c381403 commit 0e00f47
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions houe-robber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
l = 0
r = 0
for num in nums:
temp = l
l = max(num + r,l)
r = temp
return l

0 comments on commit 0e00f47

Please sign in to comment.