We consider sorting according to the max of each interval,
then shoot from the max of the smallest max interval,
see how much can be shot each time,
and then take the smallest max interval that has not been exploded, and then shoot from max, statistics frequency
class Solution:
def __init__(self):
self.points = None
def findMinArrowShots(self, points: List[List[int]]) -> int:
self.points = sorted(points,key=lambda x:x[1])#,x[1]
suma = 0
while self.points != []:
arrow = self.points[0][1]
self.points.pop(0)
tempsum = self.inlist(arrow,self.points)
for i in range(tempsum):
self.points.pop(0)
suma += 1
return suma
def inlist(self,value,otherlists):
temp = 0
for onelist in otherlists:
if value >= onelist[0]:
temp += 1
else:
break
return temp