House Robber 打家劫舍

2017年9月6日21:18:29 发表评论 31

198. 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.

给出一个代表每个房子的非负整数的列表,确定你今天晚上可以抢劫的最大金额,而不提醒警察。

递归暴力求解(自顶向下)

递推暴力求解(自底向上)

递推是没有重叠子问题的

动态规划求解

类似问题

斐波那契

阶乘递归

组合问题

走棋盘问题

上楼梯问题

 

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: