cheetcode

101. House RobberMedium

Maximize the money you can rob without taking adjacent houses.

You are a robber planning to rob houses along a street. Each house has some amount of money stashed.

You cannot rob two adjacent houses. Return the maximum amount you can rob tonight.

Examples

Input: nums = [1,2,3,1]
Output: 4
Input: nums = [2,7,9,3,1]
Output: 12

Constraints

  • 1 <= nums.length <= 100
  • 0 <= nums[i] <= 400