https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons

This problem is almost identical to problem 435 Non-overlapping Intervals, but here we need to find not how many interals we need to remove, but how many non-overlapping intervals we have. Also one small difference is that here intervals [1,2] and [2,3] overlapping, because they have common end.

For more explanations, please look at my solution of problem 435: https://leetcode.com/problems/non-overlapping-intervals/discuss/793070/Python-O(n-log-n)-sort-ends-with-proof-explained

Complexity: it is the same as problem 435: time is O(n log n) and space is O(n).

class Solution:
    def findMinArrowShots(self, points):
        points.sort(key = lambda x: x[1])
        n, count = len(points), 1
        if n == 0: return 0
        curr = points[0]
        
        for i in range(n):
            if curr[1] < points[i][0]:
                count += 1
                curr = points[i]
                
        return count  

If you like the solution, you can upvote it on leetcode discussion section: Problem 0452