Non overlapping intervals | Leetcode

  Рет қаралды 36,803

Techdose

Techdose

Күн бұрын

Пікірлер: 73
@shayestaparveen315
@shayestaparveen315 2 жыл бұрын
Thanks!
@amalsalim88
@amalsalim88 4 жыл бұрын
so this is maybe the fourth or fifth time im stumbling upon tech does solution and your videos are really good. you focus on explaining the algorithm. thanks so much for making my life easier
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@shaleen0mishra
@shaleen0mishra 2 жыл бұрын
Could not get my head around this problem/solution even after referencing multiple 'good' resources. This helped a lot. Great job explaining!
@K_EC_AushoRoup
@K_EC_AushoRoup 3 жыл бұрын
16/18 test cases passed. I am here because of the remaining test cases. Update: And @7:25 I got my mistake, I was ignoring or leaving the case when one interval will lie completely inside of the other interval. For example, [2,3] is completely inside the [1,4]. And when I handle those case, 18/18 test cases passed. Thanks, sir for such a diagrammatical explanation.
@techdose4u
@techdose4u 3 жыл бұрын
Welcome :)
@deepanshjohri3997
@deepanshjohri3997 11 ай бұрын
Thanks alot sir, I stopped the video at 11:47 and implement the whole code by myself 🙏🙏
@justshanky3012
@justshanky3012 3 жыл бұрын
Thank you so much. This looked like a very complicated problem at first. You made it so much simpler
@yjj410
@yjj410 4 жыл бұрын
This is similar to problem where arrival/start and departure/end times are given and we have to give maxim number of guests or trains or events that can happen without collision.
@techdose4u
@techdose4u 4 жыл бұрын
Seems the same.
@shubhamrathi3734
@shubhamrathi3734 3 жыл бұрын
I dont see how. In the problem where arrival/start and departure/end times are given and we have to give maximum number of platforms, we dont care about the start time or the end time. In this problem, we very much care about the start times and the end times.
@vcfirefox
@vcfirefox 3 жыл бұрын
please keep doing this for many problems. it is VERY hard to find someone explaining the thought process instead of just writing some code on the videos. keep up the excellent work and I wish you the best of luck
@techdose4u
@techdose4u 3 жыл бұрын
Thanks 😊
@paragroy5359
@paragroy5359 9 ай бұрын
Thanks a lot for making such videos. Great Content
@adityaojha2701
@adityaojha2701 3 жыл бұрын
Thanks Tech Dose once again!! Keep posting questions like this.
@techdose4u
@techdose4u 3 жыл бұрын
👍🏼
@大盗江南
@大盗江南 11 ай бұрын
thank you soooooo much. after working at MS for 2 years, i restart my job hunting journey lol.
@imranimmu4714
@imranimmu4714 Жыл бұрын
Couldnt have found bettter explanation. Thank you.
@pryansh_
@pryansh_ Жыл бұрын
No offence madarsa boy but it should have been "couldn't". There is a spelling error too. Ask from them.
@codelite700
@codelite700 2 жыл бұрын
Wow, this was much more intuitive.
@johncenakiwi
@johncenakiwi 3 жыл бұрын
Amazing explanation. Coded it with ease. Thank you !
@techdose4u
@techdose4u 3 жыл бұрын
Welcome 😊
@krishnakantsharma6161
@krishnakantsharma6161 4 жыл бұрын
wow you r awesome u explain each and every corner 👏👏 keep it up i m watching all ur videos
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@girikgarg8
@girikgarg8 2 жыл бұрын
In overalapping case 2 at 6:52, what if I remove the left interval instead of the right one? Does it make a difference?
@kaushaljalan2928
@kaushaljalan2928 4 жыл бұрын
Great effort put up for such an awesome explanation.
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@rakeshsahni_
@rakeshsahni_ 4 жыл бұрын
Before it I am frustrated but now I fill better Thanks sir
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@Ice-2706
@Ice-2706 4 жыл бұрын
@TECH DOSE you doing a great job! btw very clear and nice explanation as always :) Cheers!
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@prasad.patil12
@prasad.patil12 4 жыл бұрын
Simple and clear explanation 👍
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@pranavsharma7479
@pranavsharma7479 2 жыл бұрын
all intervals problems are solved by this template thanks a ton
@shubhamagarwal8297
@shubhamagarwal8297 Жыл бұрын
What is the proof for case 2 ? we are removing one of the intervals - greedily removing which one will be better ? Its simply - earlier ending point is given preference case 2 and 3 almost same
@BravePro
@BravePro Жыл бұрын
Didn't get it either. Why remove the one that starts later and ends later? I think it's about that there's more chance that it will be inside another interval later but I can't prove it. It's one of those problems that you shouldn't be thinking too much. Memorize the solution and the *trick* and that's it.
@rachitchaurasia1270
@rachitchaurasia1270 3 жыл бұрын
just a very small change in this code and we can do this problem also :) :- 452. Minimum Number of Arrows to Burst Balloons
@dovyraj1272
@dovyraj1272 4 жыл бұрын
Sir can v use , DP and longest increasing sub sequence ?
@Ice-2706
@Ice-2706 4 жыл бұрын
yes I have use and got the correct result but this is more efficient approach
@techdose4u
@techdose4u 4 жыл бұрын
Yep.
@ekengineer9868
@ekengineer9868 2 жыл бұрын
Awesome Explanatoin
@thinkverse94
@thinkverse94 4 жыл бұрын
Nice one.. How you write in such a beautifully .. Are you using mouse only or any electronic writing pad to make video?
@techdose4u
@techdose4u 4 жыл бұрын
Tablet
@AI_for_funn
@AI_for_funn 3 жыл бұрын
u are the saviour
@hardiksardhara3355
@hardiksardhara3355 4 жыл бұрын
Great explanation
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@jd3287
@jd3287 Жыл бұрын
what about a case 4 where for a interval, there are multiple intervals overlapping?
@_inspireverse___
@_inspireverse___ 2 жыл бұрын
What's the problem if sort the array in ascending order and removing the interval having larger gap.Because any interval having larger gap ka overlap with max number of intervals. Please Tell 🙏🙏
@shaswatdas6553
@shaswatdas6553 4 жыл бұрын
need correction in 2nd cond i guess if(intervals[left][1]
@abhisheksaraf2616
@abhisheksaraf2616 3 жыл бұрын
I think we can solve it via dynamic programming also but complexity would be N2
@therealaspirant1882
@therealaspirant1882 4 жыл бұрын
awesome explination bro
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@tarungopal3065
@tarungopal3065 4 жыл бұрын
Superb explanation....
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@c.4469
@c.4469 2 жыл бұрын
How do I prove that this problem can be solved with a greedy approach?
@Voice_Of_Thoughts
@Voice_Of_Thoughts 4 жыл бұрын
Nice explanation
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@InvincibleMan99
@InvincibleMan99 3 жыл бұрын
Thanks
@aayush5474
@aayush5474 4 жыл бұрын
Bhaiya aapne mtech ke baad samsung join kiya na? Toh abhi app sde1 ho ya sde2?
@drishtdyumnshrivastava5313
@drishtdyumnshrivastava5313 4 жыл бұрын
misssed 1 condn....btw tnks for the help
@techdose4u
@techdose4u 4 жыл бұрын
👍
@sudhanshusingh211
@sudhanshusingh211 3 жыл бұрын
can we do it by lcs by sorting by first ???
@hapysethi1306
@hapysethi1306 4 жыл бұрын
Sir in case 2, can we use Interval [left] [1] > interval [right] [0]. Instead of Interval [left] [1] < interval [right] [1]
@shaswatdas6553
@shaswatdas6553 4 жыл бұрын
Interval [left] [1] > interval [right] [0] this does not ensure that they are overlapping case 1, and they may be overlapping case 2 also. eg: (2,10) and (3,9) 0-------L----------------1 0----R----1 here L(1)>R(0)
@pranavsharma7479
@pranavsharma7479 2 жыл бұрын
@@shaswatdas6553 thnks had same doubt
@amitavamozumder73
@amitavamozumder73 3 жыл бұрын
I tried to do a LIS on the sorted array :P , but this seems faster.
@vijayakumareyunni6010
@vijayakumareyunni6010 2 жыл бұрын
I think the total video time can be reduced by "not reading the input array elements" and avoiding explaining some simple steps. Also, the "overlapping case-3 of case-2 titles" are confusing. To understand the strategy to solve this, one need to wait almost 75% of the time! Thanks for your effort, but, with some improvements your videos will be very helpful.
@rakshith3547
@rakshith3547 4 жыл бұрын
just wow
@techdose4u
@techdose4u 4 жыл бұрын
😃
@shaswatdas6553
@shaswatdas6553 4 жыл бұрын
Python code: def non_overlapping(arr): arr.sort(key=lambda x: [0]) left = 0 right = 1 count = 0 n = len(arr) while right < n: if arr[left][1] =R[0] ''' 0------L--------1 0----R--1 ''' count+=1 left=right right+=1 print(count) ip = [(0, 3), (2, 6), (4, 6), (6, 8)] non_overlapping(ip)
@joshithmurthy6209
@joshithmurthy6209 2 жыл бұрын
thanks
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 761 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 603 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 348 М.
Reconstruct Itinerary | Leetcode #332
17:36
Techdose
Рет қаралды 35 М.
The unfair way I got good at Leetcode
6:47
Dave Burji
Рет қаралды 533 М.
Who is Smarter? Engineer vs Chinese 5th Grader
21:08
Cantomando
Рет қаралды 924 М.
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 2,7 МЛН
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 244 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 327 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН