You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
3
+
4
+
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.
5
+
6
+
Example 1:
7
+
8
+
Input: [2,3,2]
9
+
Output: 3
10
+
Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2),
11
+
because they are adjacent houses.
12
+
Example 2:
13
+
14
+
Input: [1,2,3,1]
15
+
Output: 4
16
+
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.
3
+
4
+
Determine the maximum amount of money the thief can rob tonight without alerting the police.
5
+
6
+
Example 1:
7
+
8
+
Input: [3,2,3,null,3,null,1]
9
+
10
+
3
11
+
/ \
12
+
2 3
13
+
\ \
14
+
3 1
15
+
16
+
Output: 7
17
+
Explanation: Maximum amount of money the thief can rob = 3 + 3 + 1 = 7.
18
+
Example 2:
19
+
20
+
Input: [3,4,5,1,3,null,1]
21
+
22
+
3
23
+
/ \
24
+
4 5
25
+
/ \ \
26
+
1 3 1
27
+
28
+
Output: 9
29
+
Explanation: Maximum amount of money the thief can rob = 4 + 5 = 9.
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.
4
+
5
+
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.
6
+
7
+
Example 1:
8
+
9
+
Input: [1,2,3,1]
10
+
Output: 4
11
+
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
12
+
Total amount you can rob = 1 + 3 = 4.
13
+
Example 2:
14
+
15
+
Input: [2,7,9,3,1]
16
+
Output: 12
17
+
Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1).
| 082 |[Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/)|[Python](./Python/remove-duplicates-from-sorted-list-ii.py)| O(n) | O(1) | Medium |
| 092 |[Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii/)|[Python](./Python/reverse-linked-list-ii.py)||| Medium |
281
-
| 138 |[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer/)|[Python](./Python/copy-list-with-random-pointer.py)| O(n) | O(n) |Hard|
281
+
| 138 |[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer/)|[Python](./Python/copy-list-with-random-pointer.py)| O(n) | O(1) |Medium|
282
282
| 160 |[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists/)|[Python](./Python/intersection-of-two-linked-lists.py)| O(n) | O(1) | Easy |
| 089 |[Gray Code](https://leetcode.com/problems/gray-code/)|[Python](./Python/gray-code.py)||| Medium |
496
496
| 166 |[Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal/)|[Python](./Python/fraction-to-recurring-decimal.py)||| Medium |
| 298 |[Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/)|[Python](./Python/binary-tree-longest-consecutive-sequence.py)| O(n) | O(1) | Medium |
639
639
| 327 |[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum/)|[Python](./Python/count-of-range-sum.py)||| Hard |
640
640
| 333 |[Largest BST Subtree](https://leetcode.com/problems/largest-bst-subtree/)|[Python](./Python/largest-bst-subtree.py)||| Medium |
641
-
| 337 |[House Robber III](https://leetcode.com/problems/house-robber-iii/)|[Python](./Python/house-robber-iii.py)||| Medium |
641
+
| 337 |[House Robber III](https://leetcode.com/problems/house-robber-iii/)|[Python](./Python/house-robber-iii.py)|O(logn)|O(1)| Medium |
642
642
| 395 |[Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/)|[Python](./Python/longest-substring-with-at-least-k-repeating-characters.py)||| Medium |
643
643
| 404 |[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/)|[Python](./Python/sum-of-left-leaves.py)||| Easy |
644
644
| 437 |[Path Sum III](https://leetcode.com/problems/path-sum-iii/)|[Python](./Python/path-sum-iii.py)||| Easy |
| 152 |[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/)|[Python](./Python/maximum-product-subarray.py)||| Medium |
843
843
| 174 |[Dungeon Game](https://leetcode.com/problems/dungeon-game/)|[Python](./Python/dungeon-game.py)||| Hard |
844
844
| 188 |[Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/)|[Python](./Python/best-time-to-buy-and-sell-stock-iv.py)||| Hard |
0 commit comments