파비의 매일매일 공부기록

Today's Challenge 본문

Problem Solving/LeetCode

Today's Challenge

fabichoi 2023. 1. 5. 23:45

https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/

 

Minimum Number of Arrows to Burst Balloons - LeetCode

Minimum Number of Arrows to Burst Balloons - There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizonta

leetcode.com

어제에 이은 탐욕법으로 풀기
뒤에서 부터 순회하면서 세면 됨

class Solution:
    def findMinArrowShots(self, points: List[List[int]]) -> int:
        points.sort()
        res, cur_start = 1, points[-1][0]

        for s, e in reversed(points):
            if e < cur_start:
                cur_start = s
                res += 1
        
        return res
반응형

'Problem Solving > LeetCode' 카테고리의 다른 글

Today's Challenge  (0) 2023.01.07
Today's Challenge  (0) 2023.01.06
Today's Challenge  (0) 2023.01.04
Today's Challenge  (0) 2023.01.03
Today's Challenge  (0) 2023.01.02
Comments