Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 844 Bytes

leetcode_452.md

File metadata and controls

33 lines (25 loc) · 844 Bytes

LeetCode Problems

452. Minimum Number of Arrows to Burst Balloons

class Solution {
    fun findMinArrowShots(points: Array<IntArray>): Int {
        // sort by endPoint ( startPoint will miss some targeting points )
        points.sortBy({ it[1] })
        var arrowCount = 1
        var target = points[0][1]
        // iterate
        for (i in 1..points.size-1) {
            // if current balloon is out of range, shot new arrow.
            if (points[i][0] > target) {
                arrowCount++
                target = points[i][1]
            }
        }
        return arrowCount
    }
}