18 lines
533 B
Python
18 lines
533 B
Python
class Solution:
|
|
def findMinArrowShots(self, points: list[list[int]]) -> int:
|
|
def rule(l):
|
|
return (l[0], l[1])
|
|
sorted_points = sorted(points, key=rule)
|
|
rlt = 0
|
|
end = -inf
|
|
for point in sorted_points:
|
|
st = point[0]
|
|
ed = point[1]
|
|
if st > end:
|
|
rlt += 1
|
|
end = ed
|
|
else:
|
|
end = min(end, ed)
|
|
return rlt
|
|
sol = Solution()
|
|
print(sol.findMinArrowShots([[10, 16],[2, 8],[1, 6], [7, 12]])) |