diff --git a/2201/220113.cpp b/2201/220113.cpp new file mode 100644 index 0000000..a2872ef --- /dev/null +++ b/2201/220113.cpp @@ -0,0 +1,24 @@ +#include +#include +#include + +class Solution { +public: + static int findMinArrowShots(std::vector>& points) { + std::sort(points.begin(), points.end(), [](const std::vector& l, const std::vector& r) { return l[1] < r[1]; }); + int ret = 0, n = points.size(); + for (int i = 0, r; i < n;) { + ++ret; + r = points[i][1]; + while (i < n && points[i][0] <= r) + ++i; + } + return ret; + } +}; + +int main() { + std::vector> v {{3,9},{7,12},{3,8},{6,8},{9,10},{2,9},{0,9},{3,9},{0,6},{2,8}}; // {{10, 16}, {2, 8}, {1, 6}, {7, 12}}; + std::cout << Solution::findMinArrowShots(v); + return 0; +} \ No newline at end of file diff --git a/2201/CMakeLists.txt b/2201/CMakeLists.txt index 7e11243..28cea6a 100644 --- a/2201/CMakeLists.txt +++ b/2201/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2201) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2201 220113-CN.cpp) \ No newline at end of file +ADD_EXECUTABLE(2201 220113.cpp) \ No newline at end of file