LeetCode 198 House Robber - Problem Statement

The problem

Houses along a street have money. You can't rob two adjacent houses (security systems will trigger). What's the maximum you can rob?

With nums = [1,2,3,1]:

  • Rob house 0 (11) and house 2 (33): total 44.
  • Can't rob 1 and 2 together (adjacent).
  • Maximum: 44.

With nums = [2,7,9,3,1]:

  • Rob houses 0, 2, 4: 2+9+1=122 + 9 + 1 = 12.
  • Or rob houses 1, 3: 7+3=107 + 3 = 10.
  • Maximum: 1212.

Constraints: 11 \le nums.length 100\le 100.