Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 198 House Robber - Problem Statement

The classic problem

Problem Statement There are nn houses in a row, and each house contains a[i]a[i] amount of cash. A robber wants to steal from these houses, but he cannot rob two consecutive houses.

You have to help him and determine the maximum amount of money the robber can get. Constraints: 1n1001 \le n \le 100 1a[i]4001 \le a[i] \le 400 Check the examples on the problem page. For a=[2,7,9,3,1]a = [2, 7, 9, 3, 1], try figuring out which houses give you the maximum total without picking two in a row.