# House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

public class Solution {
public int rob(int[] nums) {
if(nums.length==0)
return 0;
if(nums.length==1)
return nums[0];
nums[1]=Math.max(nums[0],nums[1]);
for(int i=2;i<nums.length;i++)
nums[i]=Math.max(nums[i-1],nums[i]+nums[i-2]);
return nums[nums.length-1];
}
}

• 本文已收录于以下专栏：

## 198. House Robber Leetcode Python

You are a professional robber planning to rob houses along a street. Each house has a certain amount...
• hyperbolechi
• 2015年03月31日 22:28
• 1260

## Leetcode 198: House Robber

House Robber Total Accepted: 642 Total Submissions: 2562You are a professional robber planning to r...
• xudli
• 2015年04月01日 02:51
• 4451

## [leetcode-337]House Robber III(java)

• zdavb
• 2016年03月27日 22:19
• 832

## Leetcode_198_House Robber

• pistolove
• 2015年08月15日 12:02
• 2130

## leetcode 337. House Robber III-动态规划|Java|Python简洁高效

• happyaaaaaaaaaaa
• 2016年03月13日 21:06
• 4654

## leetCode198-House Robber

• Lu597203933
• 2015年04月01日 18:28
• 7414

## 198. House Robber [easy] (Python)

• coder_orz
• 2016年06月01日 14:39
• 1381

## 【LeetCode-面试算法经典-Java实现】【198-House Robber（抢劫犯）】

【189-House Robber（抢劫犯）】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题　　Y...
• DERRANTCM
• 2015年08月25日 06:41
• 3829

## [leetcode] 337. House Robber III

The thief has found himself a new place for his thievery again. There is only one entrance to this a...
• TstsUgeg
• 2016年03月12日 20:20
• 2335

## LeetCode_198. House Robber_动态规划

198. House Robber You are a professional robber planning to rob houses along a street. Each house ...
• Binbin_Sun
• 2016年01月21日 12:45
• 443

举报原因： 您举报文章：House Robber 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)