【LeetCode】 198. House Robber
来源:互联网 发布:cacti后台sql注入漏洞 编辑:程序博客网 时间:2024/06/05 04:48
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[] num) { int[][] dp = new int[num.length + 1][2]; for (int i = 1; i <= num.length; i++) { int prev = i - 1; dp[i][0] = Math.max(dp[prev][0], dp[prev][1]); dp[i][1] = num[prev] + dp[prev][0]; } return Math.max(dp[num.length][0], dp[num.length][1]); }}
0 0
- [LeetCode]198.House Robber
- 【LeetCode】198. House Robber
- 【LeetCode】198.House Robber
- LeetCode 198. House Robber
- [leetcode] 198.House Robber
- [leetcode] 198. House Robber
- LeetCode:198. House Robber
- 198. House Robber LeetCode
- [LeetCode]198. House Robber
- LeetCode || 198. House Robber
- LeetCode-198. House Robber
- [LeetCode]198. House Robber
- 【LeetCode】198. House Robber
- LeetCode#198. House Robber
- LeetCode 198. House Robber
- leetcode 198. House Robber
- LeetCode *** 198. House Robber
- leetcode 198. House Robber
- Spring基础:快速入门spring cloud(5):断路器之Hystrix
- 电信说的几兆带宽和自己看到的下载/上传速度有什么关系?
- 【杭电OJ从头刷】HDU1001
- [接口设计]从客户端的角度设计后端的接口
- 欢迎使用CSDN-markdown编辑器
- 【LeetCode】 198. House Robber
- Math的成员变量和方法
- 软件测试学习笔记 - 1 - 软件缺陷,测试员目标
- bzoj 2827 千山鸟飞绝 平衡树
- random()方法获得一定范围内的随机数
- [数据库]mysql死锁问题分析
- oracle 如何查询当前连接的用户名
- Leetcode 415. Add Strings
- DSP 中的基础算法和模型的详细解析