# House Robber

Category

DP - 1D

Checkbox

Checkbox

Difficulty

Medium

Index

61

Key Ideas

The key idea to solve this problem is to use dynamic programming to calculate the maximum amount of money that can be robbed from a row of houses.

Problem Number

198

Problem Summary

The House Robber problem (Problem Number: 198) is a medium difficulty dynamic programming problem in the LeetCode-75 curated list. The goal is to determine the maximum amount of money you can rob from a row of houses without robbing adjacent houses. A key pitfall to watch out for is the need to consider the cumulative maximum amount of money for each house, taking into account whether or not the current house is robbed.

Solution Summary

The best solution for the House Robber problem involves using dynamic programming. We can create an array to store the maximum amount of money that can be robbed at each house. To calculate the maximum amount for each house, we take the maximum of robbing the current house plus the maximum amount from two houses ago, or skipping the current house and taking the maximum amount from the previous house. By iterating through the array, we can determine the maximum amount of money that can be robbed from all the houses. This solution has a time complexity of O(n), where n is the number of houses.

Tags

Array

Dynamic Programming