0
0

More than 1 year has passed since last update.

Leetcode 452. Minimum Number of Arrows to Burst Balloons

Posted at

難易度

Medium

アプローチ

Brute-force

class Solution {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, (a, b) -> Integer.compare(a[1],b[1]));

        int result = 1;
        int prev = 0;

        for(int curr = 1 ; curr < points.length; curr++){
            if(points[curr][0] > points[prev][1]){
                result++;
                prev = curr;
            }
        }
        return result;
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0