Merge Intervals (LeetCode 56) | Full Solution with diagrams and visuals | Interview Essential

  Рет қаралды 28,581

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 37
@ParameswariAngalakuditi
@ParameswariAngalakuditi 2 ай бұрын
whenever i see u have explained the leet code which am searching, i feel relieved 😊
@bingochipspass08
@bingochipspass08 9 ай бұрын
Great solution! I was confused as to why we were sorting intervals based on the starting value: "We want to find values closer to the start & not farther from it since it'll give us a higher chance of finding overlap..."
@arjunjadhav6275
@arjunjadhav6275 Жыл бұрын
now i can see improvement in myself, I solved this problem with exactly same approach ,though it took me two hours😅 and came here to see more optimized solustion
@shrirambalaji2915
@shrirambalaji2915 Жыл бұрын
Thank you so much brother...I just start watching your video 3 min into the video and I code the solution without completely watching the video. Your explanation is on point thank you again
@nikoo28
@nikoo28 Жыл бұрын
Cheers man!!
@ruchivora1190
@ruchivora1190 Ай бұрын
Thank you for the visual representation of the problem. It became much simpler to understand the solution
@spacelovertelugu44spacelov46
@spacelovertelugu44spacelov46 Жыл бұрын
Topnotch best explanation for this problem
@shivaniverma4266
@shivaniverma4266 10 ай бұрын
thank you nikhil you are doing great for creating such beautiful content for us , thats what make you unique fro other teachers your explaination keep doing keep posting , u inspire us
@prashanthshetty8337
@prashanthshetty8337 9 ай бұрын
Thank you very much for the great explanation and the solution to the problem. I got confused with the naming of interval and newInterval variables in the code, which could be used other way.
@nandhakumarkr3147
@nandhakumarkr3147 6 ай бұрын
Your tutorial is just awesome
@AmitKumar-cp1oz
@AmitKumar-cp1oz 4 күн бұрын
Great Explanation!
@shaikhanuman8012
@shaikhanuman8012 3 ай бұрын
Tqs for clear cut explanation on merge intervals. Tq very much
@poojarj055
@poojarj055 14 күн бұрын
Very nicely explained. Thanks!
@nikoo28
@nikoo28 13 күн бұрын
You are welcome!
@AmitKumar-cp1oz
@AmitKumar-cp1oz 4 күн бұрын
Bro, please make a website for yourself for all the problems you have solved, it will be really helpful to follow your roadmap.
@pravinrathod1676
@pravinrathod1676 25 күн бұрын
Hi Sir, Please make video on 31. Next Permutation leetcode problem
@abhcode
@abhcode 4 ай бұрын
wonderful explanation!! 🌟I would love to see you sharing some java essentials for coding in leetcode I was not knowing methods like asList and use of comparator . So thats the problem I phased int this video .Hope you will come up with video for this!! Eagerly waiting 👀 Lots of love❤
@Divya-qt1cf
@Divya-qt1cf Жыл бұрын
Great explanation 🎉
@everyontech2716
@everyontech2716 Жыл бұрын
using stack class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: # by using sort function, we use lamba to select key, in which x is our key # intervals.sort(key = lambda x:x[0]) # without it fail when intervals = [[1,4],[0,4]] stack = [] for i in range(0,len(intervals)): # if stack not empty if stack and stack[0][1] >= intervals [i][0]: # overlapping condition comes..now update end point stack[0][1] = max(stack[0][1], intervals[i][1]) else: stack.insert(0,intervals[i]) # print(i) return stack
@kalyanamvenumadhav2245
@kalyanamvenumadhav2245 Жыл бұрын
Please Explain 4Sum Problem so that it can be helpful to all of us.
@nikoo28
@nikoo28 Жыл бұрын
Yep..will make a video on it too.
@YasarNaser-mr3if
@YasarNaser-mr3if 5 ай бұрын
Which platform you use to explain the question in Problem Statements and Description?
@nikoo28
@nikoo28 5 ай бұрын
GoodNotes 6
@pchatterjee21
@pchatterjee21 Ай бұрын
I have a doubt. Can anybody clear that please? If interval[0]
@plutomessi21
@plutomessi21 Жыл бұрын
Thanks bhaiya
@samiranroyy1700
@samiranroyy1700 12 күн бұрын
wonderful explanation!! 🌟 sir but the question is not easy..........
@subee128
@subee128 11 ай бұрын
Thanks
@unemployedcse3514
@unemployedcse3514 4 ай бұрын
awesome ❤
@sachinsoma5757
@sachinsoma5757 Жыл бұрын
public int[][] merge(int[][] intervals) { int n = intervals.length; int[][] ans = new int[n][2]; Arrays.sort(intervals, new Comparator() { public int compare(int[] a, int[] b) { return a[0] - b[0]; } }); int ansIx = 0; ans[ansIx][0] = intervals[0][0]; ans[ansIx][1] = intervals[0][1]; for(int i = 1;i
@SuriyaT3001
@SuriyaT3001 Жыл бұрын
i think in if(condition) you used newinterval[1] instead of result[1] ... Becoz i see here you dont update the value in result list .. in else codition you updated new interval value ...am i right?..
@nikoo28
@nikoo28 Жыл бұрын
check it out...we do update the result list in the else block :)
@daffapradana8557
@daffapradana8557 Жыл бұрын
​@@nikoo28 can you explain how do you update the result list in the else block? because i've only seen `result.add(newInterval)` and to my knowledge add is like pushing an element to a list. so am i missing something? or is there something that is wrong to my knowledge? because at the first you've already pushed the [1,3] into the result, and when did the result become [1,6] ? because i don't see any .set() function being called.
@apratimkundu2308
@apratimkundu2308 Жыл бұрын
@@daffapradana8557 it's getting updated in the if block where the newInterval[1] gets updated to the max. else block is for the disjoint array
@phaneendra_guduru
@phaneendra_guduru Ай бұрын
@@daffapradana8557 same doubt
@manavgora
@manavgora 4 ай бұрын
I am putting you over striver
@gyandeepdigra8461
@gyandeepdigra8461 Жыл бұрын
nice yr
@onkardheemate1066
@onkardheemate1066 5 ай бұрын
Salute you sir🫡🫡🫡
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 11 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 191 МЛН
Merge Overlapping Intervals | Brute, Optimal with Precise TC analysis
22:35
LeetCode in C# | 56. Merge Intervals
8:04
Josh Ackland
Рет қаралды 181
Merge Intervals | Leetcode | Problem-6 | Brute-Optimal | C++/Java
11:00
L8. Non Overlapping Intervals | Greedy Algorithms Playlist
8:46
take U forward
Рет қаралды 29 М.
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 11 МЛН