|
1 | 1 | [#0198-house-robber]
|
2 |
| -= 198. House Robber |
| 2 | += 198. 打家劫舍 |
3 | 3 |
|
4 |
| -:stem: latexmath |
| 4 | +https://leetcode.cn/problems/house-robber/[LeetCode - 198. 打家劫舍 ^] |
5 | 5 |
|
6 |
| -{leetcode}/problems/house-robber/[LeetCode - House Robber^] |
| 6 | +你是一个专业的小偷,计划偷窃沿街的房屋。每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,*如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警*。 |
7 | 7 |
|
8 |
| -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*. |
| 8 | +给定一个代表每个房屋存放金额的非负整数数组,计算你 *不触动警报装置的情况下* ,一夜之内能够偷窃到的最高金额。 |
9 | 9 |
|
10 |
| -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*. |
| 10 | +*示例 1:* |
11 | 11 |
|
12 |
| -*Example 1:* |
| 12 | +.... |
| 13 | +输入:[1,2,3,1] |
| 14 | +输出:4 |
| 15 | +解释:偷窃 1 号房屋 (金额 = 1) ,然后偷窃 3 号房屋 (金额 = 3)。 |
| 16 | + 偷窃到的最高金额 = 1 + 3 = 4 。 |
| 17 | +.... |
13 | 18 |
|
14 |
| -[subs="verbatim,quotes,macros"] |
15 |
| ----- |
16 |
| -*Input:* [1,2,3,1] |
17 |
| -*Output:* 4 |
18 |
| -*Explanation:* Rob house 1 (money = 1) and then rob house 3 (money = 3). |
19 |
| - Total amount you can rob = 1 + 3 = 4. |
20 |
| ----- |
| 19 | +*示例 2:* |
21 | 20 |
|
22 |
| -*Example 2:* |
| 21 | +.... |
| 22 | +输入:[2,7,9,3,1] |
| 23 | +输出:12 |
| 24 | +解释:偷窃 1 号房屋 (金额 = 2), 偷窃 3 号房屋 (金额 = 9),接着偷窃 5 号房屋 (金额 = 1)。 |
| 25 | + 偷窃到的最高金额 = 2 + 9 + 1 = 12 。 |
| 26 | +.... |
23 | 27 |
|
24 |
| -[subs="verbatim,quotes,macros"] |
25 |
| ----- |
26 |
| -*Input:* [2,7,9,3,1] |
27 |
| -*Output:* 12 |
28 |
| -*Explanation:* Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1). |
29 |
| - Total amount you can rob = 2 + 9 + 1 = 12. |
| 28 | +*提示:* |
| 29 | + |
| 30 | +* `+1 <= nums.length <= 100+` |
| 31 | +* `+0 <= nums[i] <= 400+` |
30 | 32 |
|
31 |
| ----- |
32 | 33 |
|
33 | 34 | == 思路分析
|
34 | 35 |
|
@@ -77,6 +78,15 @@ include::{sourcedir}/_0198_HouseRobber.java[tag=answer]
|
77 | 78 | include::{sourcedir}/_0198_HouseRobber_2.java[tag=answer]
|
78 | 79 | ----
|
79 | 80 | --
|
| 81 | +
|
| 82 | +三刷:: |
| 83 | ++ |
| 84 | +-- |
| 85 | +[{java_src_attr}] |
| 86 | +---- |
| 87 | +include::{sourcedir}/_0198_HouseRobber_3.java[tag=answer] |
| 88 | +---- |
| 89 | +-- |
80 | 90 | ====
|
81 | 91 |
|
82 | 92 | == 参考资料
|
|
0 commit comments