DeepRest

Minimum Number of Arrows to Burst Balloons

Jan 12th, 2022
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. class Solution:
  2.     def findMinArrowShots(self, points: List[List[int]]) -> int:
  3.         points.sort()
  4.         res = 0
  5.         pos = float("-inf")
  6.         for a, b in points:
  7.             if a > pos:
  8.                 res += 1
  9.                 pos = b
  10.             else:
  11.                 pos = min(pos, b)
  12.         return res
Advertisement
Add Comment
Please, Sign In to add comment