E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
robber
House
Robber
III
二刷吧。。不知道为什么houserobbery系列我找不到笔记,不过印象中做了好几次了。不是很难,用的post-order做bottom-up的运算。对于一个Node来说,有2种情况,一种是选(自己+下下层);一种是选左右children.其实就是选自己和不选自己的区别。其实更像是dfs的题而不是DP的题。Time:O(n)Space:O(lgn)publicclassSolution{publi
哇呀呀..生气啦~
·
2016-12-03 07:00
House
Robber
,213. House
Robber
II
普通版:首位两个房子不是连在一起的。题目:Note:ThisisanextensionofHouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthispl
caoyan_12727
·
2016-11-15 22:59
leetcode算法
House
Robber
(窃贼的计划)
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedanditw
迷知凡
·
2016-11-10 21:11
LeetCode题集
LeetCode学习篇十四——House
Robber
题目:Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedand
chender_sysu
·
2016-11-01 13:21
学习篇
House
Robber
III
Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhousesi
a_void
·
2016-09-28 21:46
House
Robber
II
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedanditw
exialym
·
2016-09-23 13:45
House
Robber
Question:Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnec
Anonymous_cx
·
2016-09-16 21:08
LeetCode
House
Robber
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedanditw
a_void
·
2016-09-14 12:50
House
Robber
III
题目:对于一个二叉树,不能同时取某个分支上两端的两个节点,求能取得的最大的值。(这是题目大意)思路:对于一个二叉树,如果根据条件判断该二叉树根节点可以取,则传入参数true,如果某个二叉树的根节点不可以取,则传入false,当参数为true时,到底真正取与不去分两种情况,类似于0-1背包问题,然后返回那个结果比较大的情况。当参数为false,则根节点一定是不能取了,则返回(root.left,tr
一天进步一点点
·
2016-09-02 09:29
leetcode
House
Robber
II | Medium | Dynamic Programming
213.HouseRobberIINote:ThisisanextensionofHouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacea
313119992
·
2016-08-31 23:49
Programming
Dynamic
leetCode练习
House
Robber
| 动态规划
198.HouseRobberYouareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystem
313119992
·
2016-08-31 21:47
动态规划
leetCode练习
leetcode-House
Robber
-198(dp)
输入一个数组,每个元素代表每个房子的价值,不能抢相邻的两个房子,求抢劫的最大值和这道二叉树的树形dp是一个系列:http://blog.csdn.net/AC_0_summer/article/details/52210957也是维护两个dp,dp1[i]表示抢第i个房子,dp2[i]表示不抢第i个房子;dp1[i]=dp2[i-1]+nums[i];dp2[i]=max(dp1[i-1],dp2
AC_0_summer
·
2016-08-28 22:23
leetcode
House
Robber
(Easy) (cpp)
Leetcode198.HouseRobber(Easy)(cpp)Tag:DynamicProgrammingDifficulty:Easy/* 198.HouseRobber(Easy) Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theo
Niko_Ke
·
2016-07-20 14:00
LeetCode
cpp
Little
Robber
Girl's Zoo 水题
B.LittleRobberGirl'sZoo题目连接:http://www.codeforces.com/contest/686/problem/BDescriptionLittleRobberGirllikestoscareanimalsinherzooforfun.Shedecidedtoarrangetheanimalsinarowintheorderofnon-decreasinghei
qscqesze
·
2016-06-25 09:00
House
Robber
II
题目描述:Note:ThisisanextensionofHouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacearearrangedin
yeshiwu
·
2016-06-22 21:00
java
LeetCode
动态规划
House
Robber
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedanditw
NNNNNNNNNNNNY
·
2016-06-11 21:00
LeetCode:House
Robber
III
HouseRobberIIITotalAccepted: 13977 TotalSubmissions: 37027 Difficulty: MediumThethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhou
itismelzp
·
2016-06-10 14:00
LeetCode
tree
search
Depth-first
【Leetcode】House
Robber
题目链接:https://leetcode.com/problems/house-
robber
/题目:Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed
yeqiuzs
·
2016-06-01 20:00
House
Robber
[easy] (Python)
题目链接https://leetcode.com/problems/house-
robber
/题目原文Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed
coder_orz
·
2016-06-01 14:22
LeetCode
LeetCode解题报告
House
Robber
III(增补1)
题目原文:Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe“root.”Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat“allho
cmershen
·
2016-05-31 20:00
House
Robber
II
题目原文:Note:ThisisanextensionofHouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacearearrangedin
cmershen
·
2016-05-31 16:00
House
Robber
题目原文:Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnecteda
cmershen
·
2016-05-30 20:00
LeetCode题解——House
Robber
III
题目:Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhous
u010025211
·
2016-05-25 19:00
LeetCode
tree
DFS
house
III
Robber
House
Robber
II
Note:ThisisanextensionofHouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacearearrangedinacirc
a342500329a
·
2016-05-13 22:00
[Leetcode]House
Robber
题意:给定一串数字,让你选择其中一些数字,选的数字不能相邻,那么选的数字的最大和是多少?我的解法:这又是一个典型的动态规划求最优的问题,但是一开始我还是没有想明白。简单的说就是这一个公式:max_sum(i)=max(max_sum(i-2)+nums[i],max_sum(i-1))java代码如下://明显是动态规划的问题 publicclassSolution{ publicintrob(
qq_28057541
·
2016-05-13 14:00
LeetCode
leetcode House
Robber
III
题目链接动态规划,可以把空间优化到线性时间/** *Definitionforabinarytreenode. *publicclassTreeNode{ *intval; *TreeNodeleft; *TreeNoderight; *TreeNode(intx){val=x;} *} */ publicclassSolution{ HashMapmapNot=newHashMap(); Has
bleuesprit
·
2016-05-11 10:00
House
Robber
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedand it
agsws
·
2016-05-11 10:00
123.House
Robber
III
Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhousesi
u010339647
·
2016-05-10 12:00
122.House
Robber
II
Note: Thisisanextensionof HouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplaceare arrangedinac
u010339647
·
2016-05-10 11:00
House
Robber
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedand it
huakaimo
·
2016-05-09 20:00
LeetCode
House
Robber
III (C++实现)
解题思路:递归求解,若为空树返回0;若只有一个根结点就返回根结点的值;否则,若根结点有孩子,两种抢法:抢根结点!不抢根结点,抢根结点的孩子子树!取最大值(选抢的多的方案)!(注:抢根结点,就不能抢根结点的孩子!但可以抢根结点的孩子的孩子~~~)C++代码:/** *Definitionforabinarytreenode. *structTreeNode{ *intval; *TreeNode*l
jingmiaa
·
2016-05-09 18:00
LeetCode
C++
House
Robber
II
解题思路:若第一座房子和最后一座房子只抢其一,去掉不抢的那栋,此题就回归到198HouseRobber的解!代码:classSolution{ #define_MAX(a,b)((a)>(b))?(a):(b) public: intfirstRob(vector&nums,intn){//此函数取自198HouseRobber,仅增加了参数列表中的intn if(n==0)return0; if
jingmiaa
·
2016-05-05 10:00
LeetCode
C++
Leetcode - House
Robber
QuestionYouareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnect
roamer_nuptgczx
·
2016-05-04 21:00
LeetCode
动态规划
Robber
【LeetCode】House
Robber
解题报告
HouseRobber[LeetCode]https://leetcode.com/problems/house-
robber
/TotalAccepted:67398TotalSubmissions:196356Difficulty
fuxuemingzhu
·
2016-05-01 21:00
LeetCode
[LintCode] House
Robber
II 打家劫舍之二
Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacearearrangedinacircle.Thatmeansthefirsthouseistheneigh
Grandyang
·
2016-04-29 12:00
[LintCode] House
Robber
打家劫舍
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedandit
Grandyang
·
2016-04-29 12:00
[LintCode] House
Robber
III 打家劫舍之三
Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhouses
Grandyang
·
2016-04-29 11:00
leetcode——337—— House
Robber
III
Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhousesi
happyxuma1991
·
2016-04-22 13:00
LeetCode
leetcode——213——House
Robber
II
Note:ThisisanextensionofHouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacearearrangedinacirc
happyxuma1991
·
2016-04-22 12:00
LeetCode
House
Robber
II
Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacearearrangedinacircle.Thatmeansthefirsthouseistheneighb
github_34333284
·
2016-04-21 07:00
House
Robber
Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedanditw
github_34333284
·
2016-04-21 06:00
House
Robber
II
Note: Thisisanextensionof HouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplaceare arrangedinac
qq_27991659
·
2016-04-20 10:00
House
Robber
III
Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhousesi
qq_27991659
·
2016-04-20 10:00
LeetCode House
Robber
I II III
第一题Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedand
jiangxishidayuan
·
2016-04-17 13:00
House
Robber
III 解题报告
题目链接: https://leetcode.com/problems/house-
robber
-iii/Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea
qq508618087
·
2016-04-13 13:00
LeetCode
DFS
House
Robber
III
Thethiefhasfoundhimselfanewplaceforhisthieveryagain.Thereisonlyoneentrancetothisarea,calledthe"root."Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhousesi
a342500329a
·
2016-04-08 20:00
House
Robber
III+198. House
Robber
HouseRobberIII对二叉树的各种操作还不太熟....一开始是自己写的程序,然而逻辑有些问题,居然认为必须隔层访问(其实隔两层/三层也是可以的...所以重点是当前访问的结点是否被计入)。参考了他人的代码,解题思路如下:针对正在访问的结点,两种情况取较大值,(1)当前结点值计入,则结果是左孩子和右孩子不计入时两个子树的count;(2)当前结点值不计入,则结果是左子树两种情况(计入/不计入)
qq_20581563
·
2016-04-06 20:00
LeetCode
《leetCode》:House
Robber
III
题目Thethiefhasfoundhimselfanewplaceforhisthieveryagain. Thereisonlyoneentrancetothisarea,calledthe"root." Besidestheroot,eachhousehasoneandonlyoneparenthouse.Afteratour,thesmartthiefrealizedthat"allhou
u010412719
·
2016-04-06 18:00
LeetCode
house
Robber
《leetCode》:House
Robber
II
题目Note:ThisisanextensionofHouseRobber.Afterrobbingthosehousesonthatstreet,thethiefhasfoundhimselfanewplaceforhisthieverysothathewillnotgettoomuchattention.Thistime,allhousesatthisplacearearrangedinaci
u010412719
·
2016-04-06 15:00
LeetCode
house
Robber
《leetCode》:House
Robber
题目Youareaprofessionalrobberplanningtorobhousesalongastreet.Eachhousehasacertainamountofmoneystashed,theonlyconstraintstoppingyoufromrobbingeachofthemisthatadjacenthouseshavesecuritysystemconnectedandi
u010412719
·
2016-04-06 11:00
LeetCode
house
Robber
上一页
5
6
7
8
9
10
11
12
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他