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

  Рет қаралды 2,940

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 7
@UECAshutoshKumar
@UECAshutoshKumar 8 ай бұрын
Thank you 😊
@fraserdab
@fraserdab 8 ай бұрын
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
@abhaykumar9612
@abhaykumar9612 8 ай бұрын
bro it can also be solved by sorting on the basis of starting point
@coderunner743
@coderunner743 8 ай бұрын
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 4 ай бұрын
Bhai faltu bakwas jyada karta he
@nerdInsaan
@nerdInsaan 8 ай бұрын
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 8 ай бұрын
me being too lazy stored all these in ans[][] & returned it's size. 🙃
206. Reverse Linked List | Iterative & Recursive
25:51
Aryan Mittal
Рет қаралды 1 М.
57. Insert Interval | 56. Merge Intervals | 2 Approaches
27:47
Aryan Mittal
Рет қаралды 4 М.
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 57 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 133 МЛН
Minimum Swaps to sort intuition + code C++ with explanation
15:25
Code with Alisha
Рет қаралды 23 М.
Winning Facebook (Meta) Hacker Cup Qual Round 2022?
53:55
Neal Wu
Рет қаралды 2,6 МЛН
Merge Overlapping Intervals | Brute, Optimal with Precise TC analysis
22:35
Players push long pins through a cardboard box attempting to pop the balloon!
00:31