###### Easy-题目26：198. 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.

dp[n]=max(dp[n-1],dp[n-2]+money[n])

int rob(int* nums, int numsSize) {
if(numsSize==0)
return 0;
if(numsSize==1)
return nums[0];
else if(numsSize==2)
return nums[0]>nums[1]?nums[0]:nums[1];
else
{
int i;
int dp1,dp2,dp;

dp1=nums[0];
dp2=nums[0]>nums[1]?nums[0]:nums[1];
for(i=2;i<numsSize;i++)
{
dp=dp2>dp1+nums[i]?dp2:dp1+nums[i];
dp1=dp2;
dp2=dp;
}
return dp;
}
}

0ms，beats3.60%，众数0ms，96.40%
Cmershen的碎碎念：

#### leetCode198-House Robber

2015-04-01 18:28:58

#### Leetcode 198: House Robber

2015-04-01 02:51:09

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

2016-06-01 14:39:22

#### 198. House Robber Leetcode Python

2015-03-31 22:28:07

#### Leetcode_198_House Robber

2015-08-15 12:02:28

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

2015-08-25 06:41:25

#### LeetCode--198. House Robber(打家劫舍)Python

2018-01-05 15:35:13

#### LeetCode 198 House Robber 打家劫舍

2016-04-14 10:16:29

#### LeetCode_198. House Robber_动态规划

2016-01-21 12:45:01

#### leetcode 198.House Robber-打家劫舍|动态规划

2016-03-08 18:45:55

## 不良信息举报

Easy-题目26：198. House Robber