Minimum Number of Arrows to Burst Balloons - Leetcode 452 - Python

  Рет қаралды 14,052

NeetCodeIO

NeetCodeIO

Күн бұрын

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
Problem Link:leetcode.com/problems/minimum...
0:00 - Read the problem
0:14 - Drawing Explanation
8:46 - Coding Explanation
leetcode 452
#neetcode #leetcode #python

Пікірлер: 24
@1vader
@1vader 2 ай бұрын
Notice that you are never using prev[0]. You don't actually need to merge intervals, it's enough to just keep track of the earliest ending point. That's the latest point where the arrow can be shot to pop the balloons so far and at that point, all the other overlapping balloons are also popped and therefore become completely irrelevant.
@yang5843
@yang5843 2 ай бұрын
A good follow-up question to intervals from yesterday's
@DeathSugar
@DeathSugar 2 ай бұрын
i've made a mess yesterday compared to today's
@sanchitbajaj02
@sanchitbajaj02 2 ай бұрын
When I read this problem, it goes over my head but after a few minutes of explanation, I thought it was almost the same as yesterday
@DebopriyoBasu
@DebopriyoBasu 2 ай бұрын
Not sure about balloons, but my head did burst. This is an excellent explanation!
@elizabeth00653
@elizabeth00653 2 ай бұрын
Love your clear engaging solutions
@dineshkumarkb1372
@dineshkumarkb1372 2 ай бұрын
Wow. Initialising the arrow count to n and decrementing was clever. I've always tripped myself up initialising result to 0 or 1. But yeah, like you said, having the result set to 1 is more intuitive as we already have a balloon in our prev variable. Ofcourse it goes without saying, Great work as always :)
@MP-ny3ep
@MP-ny3ep 2 ай бұрын
Great explanation as always. Thank you
@SC2Edu
@SC2Edu 2 ай бұрын
Super clear as usual, thanks
@pastori2672
@pastori2672 2 ай бұрын
what if they miss
@kanishkkala16
@kanishkkala16 2 ай бұрын
my intuition was also to decrement from n
@sauravsingh4497
@sauravsingh4497 2 ай бұрын
For once when I read the title I thought the problem was the crackhead problem "burst balloons"
@LlamaBG
@LlamaBG 2 ай бұрын
awesome
@eleven-2806
@eleven-2806 2 ай бұрын
can someone tell me why this cant be solved by merge intervals and returning size?
@mahesh_bvn
@mahesh_bvn 2 ай бұрын
Hey, can you solve leetcode 790(Domino and Tromino Tiling). Seems baffling
@sidhartheleswarapu
@sidhartheleswarapu 2 ай бұрын
We can just track the end of the previous interval in a variable prevEnd. No need to care about the starting value of the previous interval.
@pastori2672
@pastori2672 2 ай бұрын
btw why is the time complexity nlong instead of n ** 2 because apparently min() takes linear time and its nested within a loop
@1vader
@1vader 2 ай бұрын
min() takes linear time over the number of elements it has to select the minimum from, which in this case is always 2, a constant. You have to be very careful with general statements like "f takes linear amount of time" without considering its inputs in relation to the input of the actual problem.
@pastori2672
@pastori2672 2 ай бұрын
@@1vader oh right you're right
@yang5843
@yang5843 2 ай бұрын
Java Solution class Solution { public int findMinArrowShots(int[][] points) { Arrays.sort(points,(a,b)->a[0]==b[0]?Integer.compare(a[1],b[1]):Integer.compare(a[0],b[0])); int rc = points.length; int[] prev = points[0]; for (int i=1;i
@ObaidKnight
@ObaidKnight 2 ай бұрын
Neet I'm losing motivation, I need some encouragement
@luciferdesuza1541
@luciferdesuza1541 2 ай бұрын
Ask your hand for it😂
@joshk9571
@joshk9571 2 ай бұрын
enjoy being broke. someone has to flip the burgers for me
@yang5843
@yang5843 2 ай бұрын
My approach was to use greedy, have a left and right bound for the first balloon, if the next balloon fits inside the bound, then don't do anything, and reduce the left and right bounds to be the min/max of the two balloons, otherwise increase the return value and set the left and right bound to be the new balloon. class Solution { public int findMinArrowShots(int[][] points) { int rc = 0; Arrays.sort(points,(a,b)->a[0]==b[0]?a[1]-b[1]:a[0]-b[0]); int i = 0; long minL = Long.MIN_VALUE; long minR = Long.MIN_VALUE; while ( i < points.length ) { int l = points[i][0]; int r = points[i][1]; // System.out.println(l+" "+r); if ( minL
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 172 М.
Hot Ball ASMR #asmr #asmrsounds #satisfying #relaxing #satisfyingvideo
00:19
Oddly Satisfying
Рет қаралды 22 МЛН
Sigma Girl Education #sigma #viral #comedy
00:16
CRAZY GREAPA
Рет қаралды 101 МЛН
Eccentric clown jack #short #angel #clown
00:33
Super Beauty team
Рет қаралды 29 МЛН
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 252 М.
Leetcode 187 - DNA Sequences (w/ Rolling Hash Solution)
12:04
Raymond Jones
Рет қаралды 102
Subarray Product Less Than K - Leetcode 713 - Python
10:26
NeetCodeIO
Рет қаралды 12 М.
Reveal Cards In Increasing Order - Leetcode 950 - Python
11:14
NeetCodeIO
Рет қаралды 14 М.
Bitwise AND of Numbers Range - Leetcode 201 - Python
18:25
NeetCodeIO
Рет қаралды 12 М.
Jump Game II - Greedy - Leetcode 45 - Python
11:58
NeetCode
Рет қаралды 167 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 594 М.
Hot Ball ASMR #asmr #asmrsounds #satisfying #relaxing #satisfyingvideo
00:19
Oddly Satisfying
Рет қаралды 22 МЛН