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 a security system connected, and it will automatically contact the police if two adjacent houses were broken into on the same night.
3
+
// 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.
4
+
// Example 1:
5
+
// Input: nums = [2,3,2]
6
+
// Output: 3
7
+
// Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2), because they are adjacent houses.
8
+
// Example 2:
9
+
// Input: nums = [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 3:
14
+
// Input: nums = [1,2,3]
15
+
// Output: 3
16
+
// Constraints:
17
+
// 1 <= nums.length <= 100
18
+
// 0 <= nums[i] <= 1000
19
+
20
+
21
+
//Approch: same as 198, but here first and last cant be include at once.
// 452. Minimum Number of Arrows to Burst Balloons
2
+
// There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend. You do not know the exact y-coordinates of the balloons.
3
+
// Arrows can be shot up directly vertically (in the positive y-direction) from different points along the x-axis. A balloon with xstart and xend is burst by an arrow shot at x if xstart <= x <= xend. There is no limit to the number of arrows that can be shot. A shot arrow keeps traveling up infinitely, bursting any balloons in its path.
4
+
// Given the array points, return the minimum number of arrows that must be shot to burst all balloons.
5
+
// Example 1:
6
+
// Input: points = [[10,16],[2,8],[1,6],[7,12]]
7
+
// Output: 2
8
+
// Explanation: The balloons can be burst by 2 arrows:
9
+
// - Shoot an arrow at x = 6, bursting the balloons [2,8] and [1,6].
10
+
// - Shoot an arrow at x = 11, bursting the balloons [10,16] and [7,12].
11
+
// Example 2:
12
+
// Input: points = [[1,2],[3,4],[5,6],[7,8]]
13
+
// Output: 4
14
+
// Explanation: One arrow needs to be shot for each balloon for a total of 4 arrows.
15
+
// Example 3:
16
+
// Input: points = [[1,2],[2,3],[3,4],[4,5]]
17
+
// Output: 2
18
+
// Explanation: The balloons can be burst by 2 arrows:
19
+
// - Shoot an arrow at x = 2, bursting the balloons [1,2] and [2,3].
20
+
// - Shoot an arrow at x = 4, bursting the balloons [3,4] and [4,5].
0 commit comments