问题描述:一个小偷去一个街区偷东西,求偷得价值最大,唯一限制就是不能偷连续的两家,因为这样会触发警报。建模:给定一个列表,里面存着每家可以偷的价值,输出最大偷到的价值。思路:动态规划如果输入是v1v2...vm,用S[i]表示从v1v2...vi能偷到的最大价值。递归子问题:S[i..
分类:
其他好文 时间:
2015-04-01 20:19:16
阅读次数:
146
链接:https://leetcode.com/problems/house-robber/
这道理可以看做是状态压缩,每两个数字看做是一行,状态有3个,故需要F[N][3]的数组,F[i][j]就表示第i行状态j时rob的money。
具体状态压缩可以看我这两篇blog: 算法练习系列—hiho1048 状态压缩一(铺地砖) 算法练习系列—hiho1044 状态压缩二(捡垃圾)
#inc...
分类:
其他好文 时间:
2015-04-01 20:03:09
阅读次数:
166
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...
分类:
其他好文 时间:
2015-04-01 17:05:33
阅读次数:
114
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...
分类:
其他好文 时间:
2015-04-01 14:48:14
阅读次数:
110
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...
分类:
其他好文 时间:
2015-04-01 01:37:01
阅读次数:
94
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 house...
分类:
其他好文 时间:
2015-03-31 22:34:11
阅读次数:
227
House Robber
Total Accepted: 212 Total
Submissions: 780My Submissions
Question
Solution
You are a professional robber planning to rob houses along a street. Each house has a certa...
分类:
其他好文 时间:
2015-03-31 22:29:10
阅读次数:
193
House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint...
分类:
其他好文 时间:
2015-03-31 21:57:29
阅读次数:
116
Problem DescriptionJack the Robber appears again! He just robbed a bank in town and is running away with a huge amount of dollar cash. Senior FBI agen...
分类:
其他好文 时间:
2015-03-21 13:53:35
阅读次数:
153
Problem Description
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 too greedy. He has decided to w...
分类:
其他好文 时间:
2015-02-24 15:10:58
阅读次数:
196