Skip to content

Commit 27b04aa

Browse files
Create README - LeetHub
1 parent 5c1cf85 commit 27b04aa

File tree

1 file changed

+43
-0
lines changed
  • 0452-minimum-number-of-arrows-to-burst-balloons

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons">452. Minimum Number of Arrows to Burst Balloons</a></h2><h3>Medium</h3><hr><p>There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array <code>points</code> where <code>points[i] = [x<sub>start</sub>, x<sub>end</sub>]</code> denotes a balloon whose <strong>horizontal diameter</strong> stretches between <code>x<sub>start</sub></code> and <code>x<sub>end</sub></code>. You do not know the exact y-coordinates of the balloons.</p>
2+
3+
<p>Arrows can be shot up <strong>directly vertically</strong> (in the positive y-direction) from different points along the x-axis. A balloon with <code>x<sub>start</sub></code> and <code>x<sub>end</sub></code> is <strong>burst</strong> by an arrow shot at <code>x</code> if <code>x<sub>start</sub> &lt;= x &lt;= x<sub>end</sub></code>. There is <strong>no limit</strong> to the number of arrows that can be shot. A shot arrow keeps traveling up infinitely, bursting any balloons in its path.</p>
4+
5+
<p>Given the array <code>points</code>, return <em>the <strong>minimum</strong> number of arrows that must be shot to burst all balloons</em>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> points = [[10,16],[2,8],[1,6],[7,12]]
12+
<strong>Output:</strong> 2
13+
<strong>Explanation:</strong> The balloons can be burst by 2 arrows:
14+
- Shoot an arrow at x = 6, bursting the balloons [2,8] and [1,6].
15+
- Shoot an arrow at x = 11, bursting the balloons [10,16] and [7,12].
16+
</pre>
17+
18+
<p><strong class="example">Example 2:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> points = [[1,2],[3,4],[5,6],[7,8]]
22+
<strong>Output:</strong> 4
23+
<strong>Explanation:</strong> One arrow needs to be shot for each balloon for a total of 4 arrows.
24+
</pre>
25+
26+
<p><strong class="example">Example 3:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> points = [[1,2],[2,3],[3,4],[4,5]]
30+
<strong>Output:</strong> 2
31+
<strong>Explanation:</strong> The balloons can be burst by 2 arrows:
32+
- Shoot an arrow at x = 2, bursting the balloons [1,2] and [2,3].
33+
- Shoot an arrow at x = 4, bursting the balloons [3,4] and [4,5].
34+
</pre>
35+
36+
<p>&nbsp;</p>
37+
<p><strong>Constraints:</strong></p>
38+
39+
<ul>
40+
<li><code>1 &lt;= points.length &lt;= 10<sup>5</sup></code></li>
41+
<li><code>points[i].length == 2</code></li>
42+
<li><code>-2<sup>31</sup> &lt;= x<sub>start</sub> &lt; x<sub>end</sub> &lt;= 2<sup>31</sup> - 1</code></li>
43+
</ul>

0 commit comments

Comments
 (0)