LeetCode-Solutions-in-Cpp17

Solutions to high-frequency interview questions of LeetCode in C++17, taking into account both efficiency and comprehensibility.


Project maintained by downdemo Hosted on GitHub Pages — Theme by mattgraham
class Solution {
 public:
  int findMinArrowShots(vector<vector<int>>& points) {
    if (empty(points)) {
      return 0;
    }
    sort(begin(points), end(points),
         [](vector<int>& x, vector<int>& y) { return x[1] < y[1]; });
    int res = 1;
    int t = points[0][1];
    for (auto& x : points) {
      if (t >= x[0] && t <= x[1]) {
        continue;
      } else {
        t = x[1];
        ++res;
      }
    }
    return res;
  }
};