Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 613 Bytes

452. Minimum Number of Arrows to Burst Balloons.md

File metadata and controls

33 lines (24 loc) · 613 Bytes

Leetcode

452. Minimum Number of Arrows to Burst Balloons

문제링크

코드

class Solution {
    func findMinArrowShots(_ points: [[Int]]) -> Int {
        var arrows: Int = 1
        var sortedArray = points.sorted(by: {$0[1] < $1[1]})
        var prev = sortedArray[0]
        
        for range in sortedArray {
            if prev[1] < range[0] {
                arrows += 1
                prev = range
            }
        }
        return arrows
    }
}

풀이 이유

참고한 내용