Skip to content

Commit 2ce9026

Browse files
authored
Merge pull request #13 from iamAntimPal/Leetcode-75
Leetcode 75
2 parents 5bc452d + 079b481 commit 2ce9026

File tree

2 files changed

+472
-0
lines changed

2 files changed

+472
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)