452. Minimum Number of Arrows to Burst Balloons | Delete overlapping intervals

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ม.ค. 2025

ความคิดเห็น • 7

  • @fraserdab
    @fraserdab 10 หลายเดือนก่อน +2

    Sort from start point, update the end point based on minimum end point each iteration,8:08 if the 3rd point is within the range of 1st point but is lesser than 1st and 2nd point's minimum end point then it will be considered seperately for another arrow

  • @UECAshutoshKumar
    @UECAshutoshKumar 10 หลายเดือนก่อน +1

    Thank you 😊

  • @abhaykumar9612
    @abhaykumar9612 10 หลายเดือนก่อน +4

    bro it can also be solved by sorting on the basis of starting point

  • @coderunner743
    @coderunner743 10 หลายเดือนก่อน

    thanks bro. today i solved my first interval based question by myself successfully because of your yesterday POTD explanation video.
    here is my code based on sorting on the starting point
    class Solution {
    public int findMinArrowShots(int[][] points) {
    int n = points.length;

    Arrays.sort(points, (a, b) -> Integer.compare(a[0], b[0]));
    int arrows = 0;
    int i = 0;
    while (i < n) {
    int end = points[i][1];
    int j = i + 1;
    while (j < n && points[j][0]

  • @atharvasuryawanshi7675
    @atharvasuryawanshi7675 5 หลายเดือนก่อน

    Bhai faltu bakwas jyada karta he

  • @nerdInsaan
    @nerdInsaan 10 หลายเดือนก่อน +1

    Just after seeing the number lines I got the logic , below is my code
    class Solution {
    public int findMinArrowShots(int[][] points) {
    Arrays.sort(points, Comparator.comparingInt((int[] arr) -> arr[0]).thenComparingInt(arr -> arr[1]));
    int itr = 0;
    int len = points.length;
    int [] prev = points[itr++];
    int count = 1;
    while(itr < len){
    if(prev[1] >= points[itr][0]){
    prev[0] = Math.min(prev[0],points[itr][0]);
    prev[1] = Math.min(prev[1],points[itr][1]);
    itr++;
    } else {
    prev = points[itr++];
    count++;
    }
    }
    return count;
    }
    }
    P.S. we can also do the same by sorting by starting point with minimal change of taking min of ending of both the points ( If someone didn't get then use notebook and dry run then you got the point)

    • @sivalokesh3997
      @sivalokesh3997 9 หลายเดือนก่อน

      me being too lazy stored all these in ans[][] & returned it's size. 🙃