Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d01336b

Browse files
solved leetcode daily challenge : 452. Minimum Number of Arrows to Burst Balloons
See: Why: How: Tags:
1 parent a064222 commit d01336b

File tree

1 file changed

+55
-0
lines changed
  • LeetCode/452._Minimum_Number_of_Arrows_to_Burst_Balloons

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <bits/stdc++.h>
2+
#include <gtest/gtest.h>
3+
using namespace std;
4+
5+
//// START
6+
/*
7+
## 452. Minimum Number of Arrows to Burst Balloons
8+
9+
*/
10+
11+
class Solution {
12+
public:
13+
int findMinArrowShots(vector<vector<int>> &points) {
14+
sort(points.begin(), points.end(),
15+
[](const vector<int> &v0, const vector<int> &v1) -> bool {
16+
if (v0[0] == v1[0]) {
17+
return v0[1] < v1[1];
18+
}
19+
return v0[0] < v1[0];
20+
});
21+
int ans = 0, arrow = 0;
22+
for (int i = 0; i < points.size(); i++) {
23+
if (ans == 0 || points[i][0] > arrow) {
24+
ans++;
25+
arrow = points[i][1];
26+
}
27+
}
28+
return ans;
29+
}
30+
};
31+
32+
//// END
33+
struct T {};
34+
35+
TEST(Solution, test) {
36+
T ts[] = {
37+
{
38+
39+
},
40+
{
41+
42+
},
43+
44+
};
45+
46+
for (T t : ts) {
47+
Solution solution;
48+
}
49+
}
50+
51+
int main() {
52+
testing::InitGoogleTest();
53+
54+
return RUN_ALL_TESTS();
55+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /