你是一个专业的小偷,计划偷窃沿街的房屋。每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。 给定一个代表每个房屋存放金额的非负整数数组,计算你在不触动警报装置的情况下,能够偷窃到的最高金额。 示例 1: 输 ...
分类:
其他好文 时间:
2018-06-20 13:06:04
阅读次数:
252
题目如下: 解题思路:和【leetcode】198. House Robber 思路一样,也是动态规划。只不过本题新增了一个约束,就是nums[0]和nums[len(nums)-1]不能同时抢。那么我们可以分别针对nums[0]抢还是不抢这两种情况做两次动态规划。如果nums[0]抢的话,那么抢劫 ...
分类:
其他好文 时间:
2018-06-19 18:25:18
阅读次数:
123
The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become t ...
分类:
其他好文 时间:
2018-06-15 22:40:18
阅读次数:
222
198. House Robbers I: 问题描述: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the ...
分类:
其他好文 时间:
2018-06-03 10:45:27
阅读次数:
138
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 yo ...
分类:
其他好文 时间:
2018-05-30 00:22:16
阅读次数:
187
2018-04-29 20:20:56 House Robber问题是leetcode上经典的系列题,这里对其中的题目做一个讲解。 198. House Robber 198. House Robber 问题描述: 问题求解: 本质上就是求解不连续取数的情况下能获得最大价值。可以使用动态规划来解决。 ...
分类:
其他好文 时间:
2018-04-30 19:47:25
阅读次数:
143
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 yo ...
分类:
其他好文 时间:
2018-04-20 22:08:09
阅读次数:
144
198 House Robber DP 0~n-1 ans=dp[n-1] dp[i] = max(dp[i-2]+nums[i], dp[i-1]) i>=2 213 House Robber II Since we cannot rob nums[0] and nums[n-1] at the ...
分类:
其他好文 时间:
2018-04-18 14:25:44
阅读次数:
148
注意事项: 这是 打家劫舍 的延伸。在上次盗窃完一条街道之后,窃贼又转到了一个新的地方,这样他就不会引起太多注意。这一次,这个地方的所有房屋都围成一圈。这意味着第一个房子是最后一个是紧挨着的。同时,这些房屋的安全系统与上次那条街道的安全系统保持一致。给出一份代表每个房屋存放钱数的非负整数列表,确定你 ...
分类:
其他好文 时间:
2018-04-08 22:38:47
阅读次数:
468
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 yo ...
分类:
其他好文 时间:
2018-04-07 17:49:30
阅读次数:
182