Minimum Number of Arrows to Burst Balloons LeetCode solution in C++
1class Solution {2public:3static bool cmp(vector<int> &a, vector<int> &b) {4return a[1] < b[1];5}6int findMinArrowShots(vector<vector<int>> &points) {7sort(points.begin(), points.end(), cmp);8// burst the first ballon at least9int arrow = 1;10int end = points[0][1];11for (int i = 1; i < points.size(); i++) {12// start time of other interval is greater than current end time means we13// need one more arrow for bursting it14if (points[i][0] > end) {15arrow++;16end = points[i][1];17}18}19return arrow;20}21};