diff --git a/198_House Robber/Solution.py b/198_House Robber/Solution.py new file mode 100644 index 0000000..cb212b3 --- /dev/null +++ b/198_House Robber/Solution.py @@ -0,0 +1,8 @@ +class Solution: + def rob(self, nums: List[int]) -> int: + prev, curr = 0, 0 + for i in nums: + temp = max(prev + i, curr) + prev = curr + curr = temp + return curr