Please watch our new video on the same topic: kzbin.info/www/bejne/f5bbf2lmoJtloNE
@sarthakchavhan2 ай бұрын
ye kya recurrsion chala rahe ho bhaiya 👀
@asutoshpanda2426Ай бұрын
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
@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
@user-je7tz6le4k Жыл бұрын
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 @@user-je7tz6le4k
@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. 📚💪
@darshanrokkad52166 ай бұрын
understanding of brute force took me more time than understanding of optimal
@OrderEmperor4 ай бұрын
To make his video in his regular pattern he intentionally adds unnecessary solutions and calls them brute force..
@anandpandey918Ай бұрын
/* 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
@shravanpai8947Ай бұрын
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-nf1cv25 күн бұрын
@@OrderEmperor Learning from him and spreading toxicity
@OrderEmperor25 күн бұрын
@@JEE-nf1cv ok bro 😂😂 still I am not wrong if you actually watch his videos
@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💯
@NithinvKumar-uk2he Жыл бұрын
One of the greatest free course that I ever seen in KZbin
@deathigniter21553 ай бұрын
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
@sayamparejiya15102 ай бұрын
nice bro but how? through practice ?
@deathigniter21552 ай бұрын
@@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
@sayamparejiya15102 ай бұрын
@@deathigniter2155 Thank for sharing.
@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
@jayrathod79578 ай бұрын
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;
@rishabh1S Жыл бұрын
Two videos in a day ✅
@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
@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
@anshikavlogs8269 Жыл бұрын
you make this question so easy to be understood by your proper explanation .🔥🔥 really thanks a lot
@wanderer_ankur7 ай бұрын
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 :)
@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
@crix_057 ай бұрын
18:33 "I am inside you" - Striver
@jatinukey40623 ай бұрын
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 ❤❤
@artifice_abhi8 ай бұрын
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
@alphaCont8 ай бұрын
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
@shubhamagarwal1434Ай бұрын
#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..
@AyushKumar-ju9jj Жыл бұрын
This man deserves a salute!
@cinime Жыл бұрын
Understood! Super amazing explanation as always, thank you so so much for your effort!!
@qjawed96544 ай бұрын
I usually don't write comment but I think this time I should. Amazing explanation Sir. Thank You
@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.
@user-sp8ne7hj3n Жыл бұрын
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 .....💖💖💖💖💖💖❤❤❤❤❤❤❤❤
@user-pq9hi1wr5z4 ай бұрын
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.
@aryanthapa55407 ай бұрын
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❤❤
@mr.kinjalchoudhary.7982Ай бұрын
while i was staring at the question i did my self come up with the optimal solution.
@deepanshudahiya89663 ай бұрын
Understood and I even made the algorithm myself before watching solution but wasnt able to write the code
@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
@souvikbasak77206 ай бұрын
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
@SAURABHKUMAR-yo7er2 ай бұрын
i was able to do the optimal solution on my own , feeling good 😌
@eklavya22k343 ай бұрын
Understood, amazing coding , love it.
@swetaacharya2969 Жыл бұрын
Thank you sir for providing such great content ❤
@priyankavasam8769 Жыл бұрын
Couldn't thank you enough sir!! You are the savior
@sarangkumarsingh79015 ай бұрын
Understood Sir...........Enjoyed this lec...........
@culeforever540810 ай бұрын
understood 🤠
@rahuljain2245 ай бұрын
Excellent explanation Thank you so much 🎉 sir
@rohitchanda84617 ай бұрын
So beautifully explained.
@studynewthings1727 Жыл бұрын
Thnk you, its helpful for me! to understand this concept very well.
@viditvaish731711 ай бұрын
amazing explanation always worth watching your videos
@AshishBharti-xr5by Жыл бұрын
i just want to say ,thank you thank you very much ..❤
@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..
@selvaarumugam370 Жыл бұрын
as usuall u jus made the problem loook easy bruh!!!!
@venkatsaireddy14127 ай бұрын
Understood Bro Thank You for Upskilling us.
@Manishgupta200 Жыл бұрын
That's really easy to understable. Thankyou
@bandlashashankreddy Жыл бұрын
Thank you for your wonderful explanation. Understood🙂
@GhostVaibhav Жыл бұрын
Understood🔥
@chandansolanki25663 ай бұрын
thank you sir , very nicely explained😊
@AniketKumar-hf2bo6 ай бұрын
understood ,thnx for the amazing expplanation ❤❤❤❤👌👌
@AmanPandey-bd1sj10 ай бұрын
Best Explanation bhaiya thanks a lot 🙏
@DeadPoolx171217 күн бұрын
UNDERSTOOD:
@harshilpatel320529 күн бұрын
Understood 🙏🏻
@bhargavijethva79586 ай бұрын
Very nice explanation!👏👏
@NazeerBashaShaik5 ай бұрын
Understood, thank you.
@pasej56 ай бұрын
Thank you bro this is good teaching
@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.
@kushagrakansal27057 ай бұрын
what is meant by ans.back()? what does it do?
@abhaypatel3792 ай бұрын
Thankyou @TUF 😮
@sumitworld918Ай бұрын
Understood ❤
@Soumyadeepd212 ай бұрын
brute force seems to be more complex than the optimize one :)....btw superb content
@Adarsh_agrahari7 ай бұрын
What a ques but apart from this what a explenation😊
@shashankgsharma09012 ай бұрын
Understood! but took lot of time.
@Vardanaggarwal7 ай бұрын
awesome explanation bhaiya
@yaxlu Жыл бұрын
Thank you! Understood!
@matbarjoshi7891 Жыл бұрын
Inspiration 🙏🏽🙏🏽
@aniketkashid828911 ай бұрын
Great Explanation Sir
@3rd_Eye_Gang Жыл бұрын
🤩🤩 Thank you Raj Bhaiya...
@user-qh3uf5gz5fАй бұрын
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?
@kirtipalve17723 ай бұрын
Can one of the solutions be using a set? We mark all the numbers within intervals in a set ranging from smallest number to the largest number in the array. Then we iterate over the set and select the consecutive numbers as one interval?
@santoshrawat3605Ай бұрын
i there is mistake in brute force check condition istead of end