We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5bc452d + 079b481 commit 2ce9026Copy full SHA for 2ce9026
Solution/198. House Robber/198. House Robber.py
@@ -0,0 +1,9 @@
1
+class Solution:
2
+ def rob(self, nums: List[int]) -> int:
3
+ @cache
4
+ def dfs(i: int) -> int:
5
+ if i >= len(nums):
6
+ return 0
7
+ return max(nums[i] + dfs(i + 2), dfs(i + 1))
8
+
9
+ return dfs(0)
0 commit comments