Tap here to switch tabs
Problem
Submissions

Problem: House Robber

House Robber gives an array of money in houses and asks for the maximum amount you can steal without robbing two adjacent houses.

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

  • 1≤1 \leq nums.length ≤103\leq 10^3
  • 0≤0 \leq nums[i] ≤1000\leq 1000
⋮
Tap here to switch tabs
Problem
Submissions

Problem: House Robber

House Robber gives an array of money in houses and asks for the maximum amount you can steal without robbing two adjacent houses.

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

  • 1≤1 \leq nums.length ≤103\leq 10^3
  • 0≤0 \leq nums[i] ≤1000\leq 1000