class Solution:
def rob(self, nums: list[int]) -> int:
a, b = 0, 0
for n in nums:
a, b = b, max(a + n, b)
return b
198. House Robber - LeetCode
ยท One min read
class Solution:
def rob(self, nums: list[int]) -> int:
a, b = 0, 0
for n in nums:
a, b = b, max(a + n, b)
return b