Search⌘ K
AI Features

House Robber

Explore how to solve the House Robber problem by maximizing the amount of money stolen from non-adjacent houses. Learn to implement an optimal solution using dynamic programming with O(n) time and O(1) space complexity. This lesson helps you build problem-solving skills for coding interviews by understanding constraints and logic to avoid security alerts.

Statement

As a skilled thief, you are planning to rob multiple houses on a street, each of which contains a substantial amount of money. However, you cannot rob the adjacent houses due to the connected security systems. Otherwise, the police will be contacted automatically.

Given an array of integers, nums, representing the amount of money present in each house, return the maximum amount of money that you can successfully steal without notifying the police.

Constraints

  • 11
...