From 38fcfafad599d39a296899a41715a07e5371a177 Mon Sep 17 00:00:00 2001 From: Shreeji <55141517+Shreejichandra@users.noreply.github.com> Date: Sat, 10 Oct 2020 21:18:08 +0530 Subject: [PATCH] Create 0452_Minimum_Number_of_Arrows_to_Burst_Balloons.py --- ...nimum_Number_of_Arrows_to_Burst_Balloons.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 LeetCode/0452_Minimum_Number_of_Arrows_to_Burst_Balloons.py diff --git a/LeetCode/0452_Minimum_Number_of_Arrows_to_Burst_Balloons.py b/LeetCode/0452_Minimum_Number_of_Arrows_to_Burst_Balloons.py new file mode 100644 index 0000000..bd55865 --- /dev/null +++ b/LeetCode/0452_Minimum_Number_of_Arrows_to_Burst_Balloons.py @@ -0,0 +1,18 @@ +class Solution: + def findMinArrowShots(self, points: List[List[int]]) -> int: + if points == []: + return 0 + points.sort(key = lambda x: x[0]) + start = points[0][0] + end = points[0][1] + ans = len(points) + for i in range(1, len(points)): + if start <= points[i][0] <= end: + ans -= 1 + if points[i][1] < end: + end = points[i][1] + else: + start = points[i][0] + end = points[i][1] + + return ans