来啊抢劫啊198. House Robber
来源:互联网 发布:淘宝劳保用品 编辑:程序博客网 时间:2024/05/17 06:05
题目如下:
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.
Credits:
Special thanks to @ifanchu for adding this problem and creating all test cases. Also thanks to @ts for adding additional test cases.
大概就是说 你抢劫就抢劫吧 没事别连着抢 不然GG
借鉴了网上大神的思想 用到了动态规划
大概介个样子
money[0]=0;
money[1]=0;
for(int t=0;t<numsSize;t++)
{
int old=money[0];
if(money[0]>money[1])
money[0]=money[0];
else money[0]=money[1];
money[1]=old+nums[t];
}
if(money[0]>money[1])
max=money[0];
else max=money[1];
return max;
- 来啊抢劫啊198. House Robber
- 213. House Robber II来啊接着抢劫
- leetcode 198. House Robber 入室抢劫 + DP动态规划求解
- Leetcode 198 House Robber 抢劫最大金额
- Leetcode 213 House Robber II 抢劫最大金额
- House Robber抢劫房屋利益最大化算法详解
- leetcode 213. House Robber II 入室抢劫 抢劫问题 + 一道经典的DP动态规划问题
- 337. House Robber III+198. House Robber
- 198. House Robber&&213. House Robber II
- 198. House Robber && 213. House Robber II
- [LeetCode]198.House Robber
- 【LeetCode】198. House Robber
- 【LeetCode】198.House Robber
- LeetCode 198. House Robber
- 198.House Robber
- [leetcode] 198.House Robber
- [leetcode] 198. House Robber
- LeetCode:198. House Robber
- Win10将资源管理器中的OneDrive移除的方法
- 计算工具类
- [by 王谭]oracle游标的使用教程
- 数据库-内连接&外连接
- 扫我服务器的目录
- 来啊抢劫啊198. House Robber
- 7、(七)外汇基础篇之外币拆借交易
- RadioGroup和RadioButton解析,以及它们的监听器
- NSUrlConnection 网络下载
- String字符串工具类
- [LeetCode] Regular Expression Matching
- bootstrap菜单代码
- js字符串转json, json转字符串
- IntelliJ IDEA(2017)