Please watch our new video on the same topic: kzbin.info/www/bejne/f5bbf2lmoJtloNE
@sarthakchavhan5 ай бұрын
ye kya recurrsion chala rahe ho bhaiya 👀
@asutoshpanda24264 ай бұрын
it could be more space optimized if u traverse it in the same place rather than creating ans to store each of them .......i passed all testcases in this approach
@takeUforward Жыл бұрын
Do give us a like if you understood everything, it won't cost you much :)
@mohdalizilani9896 Жыл бұрын
Hey Bro! 🎉 Your Graph and DP series is absolutely fantastic! 👌 Your content is top-notch and stands out from the rest. I've been searching everywhere, and your quality is unmatched. 😍 I do have a humble request - could you consider creating a compact playlist on Digit DP? Lately, I've encountered several LeetCode contests with questions related to Digit DP, and I'm struggling to crack them. I'm sure many of us are in the same boat. 💡 If you're on board with the idea of adding videos on DIGIT DP, please show your support by giving this comment a thumbs up! 👍 Let's learn and grow together. 📚💪
@Akash-yr2if Жыл бұрын
This is the first question where I took 1hr to understand the Brute force & 10 min to understand the Optimal logic 🙂
@tot7997 Жыл бұрын
22 min ka to vvideo he lodu
@Akash-yr2if Жыл бұрын
@@tot7997 Comment parke samajna ka dimak bhi chahihe chomu
@tot7997 Жыл бұрын
@@Akash-yr2if thoda humor bhi chahiye ig
@TathagatTiwari-t6b Жыл бұрын
coz both are the same... I mean he just decreases the complexity from O(2*n) to O(n) and for Java it didn't even do that bcoz we have to convert a list to an array at the end, So it remains O(2*n)
@nuclearbaba1769 Жыл бұрын
no problem bro we are playing with logic we don't take seriously to converting languages complexity @@TathagatTiwari-t6b
@darshanrokkad52169 ай бұрын
understanding of brute force took me more time than understanding of optimal
@OrderEmperor7 ай бұрын
To make his video in his regular pattern he intentionally adds unnecessary solutions and calls them brute force..
@anandpandey9184 ай бұрын
/* Given two intervals, [a, b] and [c, d], the condition for these intervals to overlap can be expressed as: a = c This condition checks if the end of the first interval (b) is not before the start of the second interval (c), and the start of the first interval (a) is not after the end of the second interval (d). If both these conditions are true, the intervals overlap. Ex : [1, 3],[2, 6] => [1, 6] [2, 9],[1, 6] => [1, 9] [1, 3], [3, 3]=> [1, 3] [1,8], [2, 3] =>[1, 8] [2, 4], [1, 8]=>[1, 8] why just not b>=c ,what is the need of a= c, these intervals would overlap because 3(b) is greater than 1 (c). However, when you look at the intervals on a timeline, you see that [8, 3] starts after [1, 6] has already ended. So, they don't actually overlap. That's why we also need the condition a
@shravanpai89473 ай бұрын
Hard work pays off brother. Here is the reason for being the first person to get placed in the batch. All the very best from your junior😇
@JEE-nf1cv3 ай бұрын
@@OrderEmperor Learning from him and spreading toxicity
@OrderEmperor3 ай бұрын
@@JEE-nf1cv ok bro 😂😂 still I am not wrong if you actually watch his videos
@NithinvKumar-uk2he Жыл бұрын
One of the greatest free course that I ever seen in KZbin
@badass_yt7962 Жыл бұрын
I generally do not comment even on good videos, but after watching this video, i really wanna say amazing explanation. You made a difficult problem easy. Excellent clarity of concept. Striver, you are the best💯
@shubhamagarwal14343 ай бұрын
#Free Education For All.. # Bhishma Pitamah of DSA...You could have earned in lacs by putting it as paid couses on udamey or any other elaerning portals, but you decided to make it free...it requires a greate sacrifice and a feeling of giving back to community, there might be very few peope in world who does this...."विद्या का दान ही सर्वोत्तम दान होता है" Hats Off to you man, Salute from 10+ yrs exp guy from BLR, India..
@syedFAHIM-el1wr Жыл бұрын
By Liking , We also tell you tube algorithm that provide us with such content instead of distracting useless videos!!! When i understood this, I started liking every quality content videos and my recommendation is now really good. Understood! I was able to build up the logic but could not code it by myself... Waiting for that magic to happen when i can code even listening to music
@Shubham-et8qkАй бұрын
Meanwhile me who remove recommendations 🗿
@sasanklakimsetti8967Ай бұрын
Understood very well. Thought that the problem would be extremely tough by looking at the question. But he proved me wrong with his explanation.
@iWontFakeIt Жыл бұрын
I think my code is more intuitive (atleast to me) rather than the code you shown.(both approaches are same) (also I am not complaining, I am sharing this so that others can also share their opinion on mine). Below is my code: #include /* intervals[i][0] = start point of i'th interval intervals[i][1] = finish point of i'th interval */ vector mergeIntervals(vector &intervals) { int n = intervals.size(); sort(begin(intervals), end(intervals)); vector ans; int i = 1; int start = intervals[0][0], end = intervals[0][1]; while(i
@jayrathod795711 ай бұрын
bro........ i just write same code but little different........... vector ans; int n=arr.size(); int lastf=-1,lasts=-1; for(int i=0;i=first) { lastf=min(lastf,first); lasts=max(lasts,second); } else{ vector temp; temp.push_back(lastf); temp.push_back(lasts); ans.push_back(temp); lastf=first; lasts=second; } } else{ lastf=first; lasts=second; } } vector temp; temp.push_back(lastf); temp.push_back(lasts); ans.push_back(temp); return ans;
@anshikavlogs8269 Жыл бұрын
you make this question so easy to be understood by your proper explanation .🔥🔥 really thanks a lot
@rishabh1S Жыл бұрын
Two videos in a day ✅
@deathigniter21555 ай бұрын
i am glad i was able to think of optimal solution directly and didnt even realised it was optimal. Felt like Brute Force was more tougher than the optimal one. LOL
@sayamparejiya15105 ай бұрын
nice bro but how? through practice ?
@deathigniter21555 ай бұрын
@@sayamparejiya1510 yes brother... i have solved like 700 problems on CF and 400 + on GFG and Codechef combined.... so it takes alot of practice. but yeah number of questions doesnt matter... Good questions matter which teach you something that you can carry to 10 next questions
@sayamparejiya15105 ай бұрын
@@deathigniter2155 Thank for sharing.
@vivekdongare22892 ай бұрын
Lol same for me xD
@wanderer_ankur10 ай бұрын
Man i have always been scared of arrays especially but after going through this sheet gradually my confidence is increasing. This is such a good resource for learning DSA. Thanks a lot striver bro for making this :)
@jatinukey40625 ай бұрын
The approaches you have taught in this video, 60-70% both the approaches come in my mind but i was struggling to implement it. Thank you very much bhaiya for this video! You are always a great tutor for me and everyone ❤❤
@mehulthuletiya497 Жыл бұрын
00:41 Problem Statement 01:15 Overlapping example 03:27 Brute force 03:56 approach 09:39 Code 13:30 Complexity 16:22 Optimal approach 16:38 Intuition 18:55 Code 21:36 Complexity
@AyushKumar-ju9jj Жыл бұрын
This man deserves a salute!
@Braveuser-x7j Жыл бұрын
when I see your video i thought why we don't get this type of teacher in our engineering college .... i think 1.5 st years is enough to crack any coding interview .....💖💖💖💖💖💖❤❤❤❤❤❤❤❤
@Astro-CoderАй бұрын
you are such an incredible teacher
@Rama-si9spАй бұрын
Sir you are god gifted teacher for us
@aryanthapa554010 ай бұрын
was watching this tutorial on your website before after watching the video I came here to just like and comment on this video to tell how beautiful the explanation was loved it striver bhaiya❤❤
@notcountdankula Жыл бұрын
Python Code 🐍 class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: ans = [] intervals.sort() ans.append(intervals[0]) for i in intervals: start = i[0] end = i[1] if start
@cinime Жыл бұрын
Understood! Super amazing explanation as always, thank you so so much for your effort!!
@qjawed96547 ай бұрын
I usually don't write comment but I think this time I should. Amazing explanation Sir. Thank You
@alphaCont11 ай бұрын
we can do it O(1) also in space, by checking the next element if it is overlapped we just change the current elements [1] element with max, than we just remove the [i+1] from the array and in the end we will have just our answer
@artifice_abhi11 ай бұрын
A little change in the code (although striver's code is shorter) by updating the end every time we move to the next index: vector overlappedInterval(vector& intervals) { // Code here sort(intervals.begin() , intervals.end()); vector ans; int start = intervals[0][0]; int end = intervals[0][1]; for(int i = 1; i
@mr.kinjalchoudhary.79824 ай бұрын
while i was staring at the question i did my self come up with the optimal solution.
@urvashi2410 Жыл бұрын
It was so easy code at the end!! Thanks Striver.
@ritikrajsinha5895 Жыл бұрын
bhaiya u re inspiration to all thrown ones like us thank u get a lot hope from u
@SAURABHKUMAR-yo7er5 ай бұрын
i was able to do the optimal solution on my own , feeling good 😌
@crix_059 ай бұрын
18:33 "I am inside you" - Striver
@swetaacharya2969 Жыл бұрын
Thank you sir for providing such great content ❤
@priyankavasam8769 Жыл бұрын
Couldn't thank you enough sir!! You are the savior
@eklavya22k345 ай бұрын
Understood, amazing coding , love it.
@Corvo183710 күн бұрын
Great explanation, understood!
@rohitchanda846110 ай бұрын
So beautifully explained.
@rahuljain2248 ай бұрын
Excellent explanation Thank you so much 🎉 sir
@studynewthings1727 Жыл бұрын
Thnk you, its helpful for me! to understand this concept very well.
@sarangkumarsingh79018 ай бұрын
Understood Sir...........Enjoyed this lec...........
@YashRaj-jt1eeАй бұрын
Superb explanation sir
@selvaarumugam370 Жыл бұрын
as usuall u jus made the problem loook easy bruh!!!!
@venkatsaireddy14129 ай бұрын
Understood Bro Thank You for Upskilling us.
@viditvaish7317 Жыл бұрын
amazing explanation always worth watching your videos
@Manishgupta200 Жыл бұрын
That's really easy to understable. Thankyou
@AshishBharti-xr5by Жыл бұрын
i just want to say ,thank you thank you very much ..❤
@deepanshudahiya89665 ай бұрын
Understood and I even made the algorithm myself before watching solution but wasnt able to write the code
@bandlashashankreddy Жыл бұрын
Thank you for your wonderful explanation. Understood🙂
So Instead of making a new int[][] ans. We can use the same given array to store answer. Which can potentially reduce the usage of extra space for storing answer.
@rickk3300 Жыл бұрын
Striver ke itne saare DSA ke videos dekh liye, ab soch kar hi ajeeb lagta hai ki bhaiya kisi zamane me CP karte the....😅
@AniketKumar-hf2bo9 ай бұрын
understood ,thnx for the amazing expplanation ❤❤❤❤👌👌
@chandansolanki25666 ай бұрын
thank you sir , very nicely explained😊
@bhargavijethva79588 ай бұрын
Very nice explanation!👏👏
@codershour Жыл бұрын
I'm still hustling, but this feeling is good
@souvikbasak77208 ай бұрын
There is an edge case, if ans.back()[0] > arr[I][0] you can put ans.back()[0] = min(ans.back()[0],arr[i][0]); in else part
@30_mithleshyadav652 ай бұрын
This case will never arise as we have already sorted the arr in the starting. So the condition ans.back()[0]>ans[i][0] will never arise
@mokshjain4985Ай бұрын
Great Work👍👍
@abhaypatel3795 ай бұрын
Thankyou @TUF 😮
@rishikeshkmr26 күн бұрын
Understood. Thanks!
@grishmitaagrawal8496Ай бұрын
UNDERSTOOD !!
@pasej59 ай бұрын
Thank you bro this is good teaching
@Adarsh_agrahari10 ай бұрын
What a ques but apart from this what a explenation😊
@Soumyadeepd215 ай бұрын
brute force seems to be more complex than the optimize one :)....btw superb content
@rajveersingh2056 Жыл бұрын
Lots of elements said: ham alag hai... Hamko apne se na jodiye.
@shivamehta6537 Жыл бұрын
Just want to ask how to remember so many optimal approaches and what to do if a question comes in an interview which I have never seen before?
@takeUforward Жыл бұрын
Comes with practice, you will get used to it.
@Vardanaggarwal9 ай бұрын
awesome explanation bhaiya
@GhostVaibhav Жыл бұрын
Understood🔥
@ShahNawaz-t7p7k4 ай бұрын
After reading the question I optimally solved by myself, I thought that this is the only way to solve and it is also marked as easy on leetcode but when I watched the brute solution, it gave me the vibe that we are forcefully creating the brute-force solution for this problem, so I don't think that it is necessary to explain brute force solution of such problems to the interviewer. What are your thoughts on this guys?
@BG-lj6fw Жыл бұрын
understood!. great as always. btw @striver the brute force code on the website is same for cpp and js (js code has been given in cpp as well ) kindly correct it.
@utsavseth6573 Жыл бұрын
Great work raj.
@NazeerBashaShaik8 ай бұрын
Understood, thank you.
@aniketkashid8289 Жыл бұрын
Great Explanation Sir
@DeadPoolx17123 ай бұрын
UNDERSTOOD:
@CodewithKing3605 ай бұрын
optimal solution is optimal to understanding than brutforce😁
@culeforever5408 Жыл бұрын
understood 🤠
@divyanjalimourya1669 Жыл бұрын
Nice explanation
@harshilpatel32053 ай бұрын
Understood 🙏🏻
@shashankgsharma09014 ай бұрын
Understood! but took lot of time.
@yaxlu Жыл бұрын
Thank you! Understood!
@matbarjoshi7891 Жыл бұрын
Inspiration 🙏🏽🙏🏽
@YourCodeVerse Жыл бұрын
Understood✅🔥🔥
@Lucifer-xt7un Жыл бұрын
Please maintain consistency brother
@DeepakPatel-d5v7 ай бұрын
Thanks a lot Bhaiya
@navneetrai95124 ай бұрын
bhai ne jayese hi bola sort krrlo , then it took just 5 min🤣🤣
@habeeblaimusa4466 Жыл бұрын
Bro, is it normal to come up with optimal solution intuition without bruteforce because, sometimes whenever a question comes up the first solution that sometimes comes up is optimal. It is sometimes hard for me to come up with bruteforce
@takeUforward Жыл бұрын
It is okay, but if you know solutions before hand, and you don't want to tell to the interviewer, drive the interview..
@her_soulmate Жыл бұрын
Understood 🎉
@Monotonic_Stack Жыл бұрын
god of dsa
@RiyaSharma-k9p10 ай бұрын
Understood striver😇
@pulkitgupta669 Жыл бұрын
Understood ❤❤
@nitinchandrasahu17748 ай бұрын
Thank You😄
@AbhishekBhattacharjee-j2m Жыл бұрын
UNDERSTOOD
@aniketbhura61315 ай бұрын
much simpler class Solution { public: vector merge(vector& nums) { vectorans; sort(nums.begin() , nums.end()); ans.push_back({nums[0][0] , nums[0][1]}); for(int i=1;i
@suyashrahatekar4964 Жыл бұрын
I thought of the same brute force approach (with O(nlogn) time) after much thought but I didnt know u can sort 2d vector like that.
@dishankbaid9809 Жыл бұрын
Amazing!
@santoshrawat36054 ай бұрын
i there is mistake in brute force check condition istead of end