Skip to content

Commit 5492bb6

Browse files
committed
🎉 [213] House Robber II
1 parent 4340ddb commit 5492bb6

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

213/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
https://leetcode.com/problems/house-robber-ii/
2+
3+
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are **arranged in a circle.** That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and **it will automatically contact the police if two adjacent houses were broken into on the same night**.
4+
5+
Given an integer array `nums` representing the amount of money of each house, return *the maximum amount of money you can rob tonight **without alerting the police***.
6+
7+
**Example 1:**
8+
9+
```
10+
Input: nums = [2,3,2]
11+
Output: 3
12+
Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2), because they are adjacent houses.
13+
```
14+
15+
**Example 2:**
16+
17+
```
18+
Input: nums = [1,2,3,1]
19+
Output: 4
20+
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
21+
Total amount you can rob = 1 + 3 = 4.
22+
```
23+
24+
**Example 3:**
25+
26+
```
27+
Input: nums = [1,2,3]
28+
Output: 3
29+
```
30+
31+
**Constraints:**
32+
33+
- `1 <= nums.length <= 100`
34+
- `0 <= nums[i] <= 1000`

213/my_solution.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
const rob = (nums) => {
6+
7+
};
8+
9+
// [2,3,2] // 3
10+
// [1,2,3,1] // 4
11+
// [1,2,3] // 3

213/solution.js

Whitespace-only changes.

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [15. 3Sum](./15/)
1111
- [198. House Robber](./198/)
1212
- [200. Number of Islands](./200/)
13+
- [213. House Robber II](./213/)
1314
- [394. Decode String](./394/)
1415

1516
---
@@ -39,6 +40,6 @@ iex ./.../solution.ex
3940

4041
Quick create in bash
4142
```ssh
42-
chapter=198 && mkdir ./$chapter && touch ./$chapter/README.md && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js
43+
chapter=213 && mkdir ./$chapter && touch ./$chapter/README.md && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js
4344
# And TOC above
4445
```

0 commit comments

Comments
 (0)