Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 770 Bytes

_198. House Robber.md

File metadata and controls

36 lines (24 loc) · 770 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : July 17, 2024

Last updated : July 17, 2024


Related Topics : Array, Dynamic Programming

Acceptance Rate : 51.64 %


Solutions

Python

class Solution:
    def rob(self, nums: List[int]) -> int:
        dp = [0, 0] + nums.copy()

        for i in range(2, len(dp)) :
            dp[i] = max(dp[i] + dp[i - 2], dp[i - 1])

        return dp[-1]