Open box-lin opened 1 year ago
452.
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
points.sort(key=lambda p: p[1])#根据尾部数值进行sort
ans, arrow = 0, 0
#遍历,利用array的尾部数值确定接下来的数组是否在范围内,如果不在,箭矢+1
for [start, end] in points:
if ans == 0 or start > arrow:
ans, arrow = ans + 1, end
return ans
452. Minimum Number of Arrows to Burst Balloons
1229. Meeting Scheduler