LEETCODE 21 (JAVASCRIPT) | MERGE TWO SORTED LISTS

  Рет қаралды 15,675

Andy Gala

Andy Gala

Күн бұрын

Hey everyone. Check out this in-depth solution for leetcode 21.

Пікірлер: 35
@indiajackson5959
@indiajackson5959 2 жыл бұрын
I have an interview with Google and your style of teaching the foundations and patterns speak to the mathematician in me!! You deserves more views!!
@andygala888
@andygala888 2 жыл бұрын
Glad the vids are helpful :)
@ayshasinara4746
@ayshasinara4746 2 жыл бұрын
yeah I agree with you 👍
@OnEwHoRiDesLinEs
@OnEwHoRiDesLinEs 9 ай бұрын
did you get the job at Google
@indiajackson5959
@indiajackson5959 9 ай бұрын
Nope lol@@OnEwHoRiDesLinEs
@Grahammpatton
@Grahammpatton 2 жыл бұрын
wow this is the best explanation. That really made me realize exactly how simple the solution is. thank you!
@fernandosalas4885
@fernandosalas4885 2 жыл бұрын
The best explanation ever. Thanks
@JoseLopez-wh7xe
@JoseLopez-wh7xe 2 жыл бұрын
Excellent, very well explained! I would say that he made it look too easy, he could have left us more so that we could deduce it ourselves, but he left everything explicit. 😊
@pinpon163
@pinpon163 2 жыл бұрын
I don't know if it is me, but it seems that the way the Linked List is implemented for this problem is not very intuitive. I am not talking about your solution, but the two lists they are giving us.
@kazno4273
@kazno4273 2 жыл бұрын
Definitely not intuitive. I'm also struggling to understand the design of linkedNode rather than the question itself
@berkantasci8811
@berkantasci8811 2 жыл бұрын
Interesting to think this was an exam question in my first year and companies like amazon and google use it in their interviews. Especially because my school was and still is kind of shit
@JaredFL
@JaredFL 2 жыл бұрын
I'm not understanding why dummy is returned instead of prev? Since prev holds the order we set
@nicolasteofilo
@nicolasteofilo 2 жыл бұрын
I'm not understanding too
@jenniferfan8155
@jenniferfan8155 2 жыл бұрын
I have the same question.
@sammi841017
@sammi841017 Жыл бұрын
I had the same question as well, but then I logged it and think that because prev was only the one we use to track the 'current node value' We get null for prev.next and prev itself is [4]
@HEBUSTORLL
@HEBUSTORLL Жыл бұрын
Basically dummy is linked and gets the pushes along the way, while prev acts like an index whosz value gets reset every time to keep track of where we're at. Returning prev would be the same as having a for loop, and returning [i]
@mrawesome1821
@mrawesome1821 Жыл бұрын
It's a little quiet, but great video. Thank you Andy!
@quangtrungo6146
@quangtrungo6146 Жыл бұрын
Thanks very much , keep doing bro.
@kirillzlobin7135
@kirillzlobin7135 Жыл бұрын
Maaan you are the legend
@Meowthrzy
@Meowthrzy Жыл бұрын
I'm having a hard time on this problem thanks!
@stephanieonyekaba8274
@stephanieonyekaba8274 2 жыл бұрын
This was very helpful ! can you zoom in a bit for future vids ? The text is kinda small :/
@anaelennaemeka4078
@anaelennaemeka4078 Жыл бұрын
Thanks Very much
@eshw23
@eshw23 Жыл бұрын
For the first output on leetcode, why the heck does it return the whole list when it is just asking for the head? That makes literlaly no sense.
@Supersoaker-xy2cr
@Supersoaker-xy2cr 2 жыл бұрын
damn thanks bro
@cmdv42
@cmdv42 Жыл бұрын
💯✨
@Wanderlustclusterfuck
@Wanderlustclusterfuck 2 жыл бұрын
hey, i have a question. i thought it said you can go from -100 to 100. why did you do -infinity?
@nid30
@nid30 2 жыл бұрын
Yes, it is quite unclear what negative infinity is doing there and what is its job?! Someone please clarifyyyy... 😢😢😭😭
@junjun22able
@junjun22able 2 жыл бұрын
@@nid30 It just a dummy, and as he said "You can set to anything". He just set it to -Infinity cause it's the lowest value in JS and just to make sense but actually you can put anything to it like 0, 100, 1000 cause it doesn't matter anyway. You will not returning this node value, only those nodes after it which is the dummy.next. I hope, I explained it well. ^___^
@nicolasteofilo
@nicolasteofilo 2 жыл бұрын
@@junjun22able great explanation
@Supersoaker-xy2cr
@Supersoaker-xy2cr 2 жыл бұрын
@@junjun22able so its just a declared head?
@melanieprevot4926
@melanieprevot4926 2 жыл бұрын
Hi, thank you for the video. Just one thing: why prev = dummy but we cannot return prev.next ? Not quite understand dummy part.
@HEBUSTORLL
@HEBUSTORLL Жыл бұрын
Because the value of prev gets re set on every loop to keep the track. Dummy is a linked node list, so it's like an empty string that you fill as loops resolves, and prev is just the index
@surajpadalkar1670
@surajpadalkar1670 Жыл бұрын
always remember if you lose your head the linked list is useless dummy is for that purpose only never lose the head of linked list as your previous is updated after every iteration it cant store it so to keep track of your head dummy is used
@_tanzil_
@_tanzil_ Жыл бұрын
Am I too newbe to understand 😢
@exe.m1dn1ght
@exe.m1dn1ght Жыл бұрын
i didn't understand one thing
Violet Beauregarde Doll🫐
00:58
PIRANKA
Рет қаралды 50 МЛН
طردت النملة من المنزل😡 ماذا فعل؟🥲
00:25
Cool Tool SHORTS Arabic
Рет қаралды 34 МЛН
LEETCODE 141 (JAVASCRIPT) | LINKED LIST CYCLE I
7:57
Andy Gala
Рет қаралды 8 М.
LEETCODE 155 (JAVASCRIPT) | MIN STACK
12:00
Andy Gala
Рет қаралды 3,8 М.
LEETCODE 232 (JAVASCRIPT) | IMPLEMENT QUEUE USING STACKS
11:19
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2,2 МЛН
LEETCODE 876 (JAVASCRIPT) | MIDDLE NUMBER
7:11
Andy Gala
Рет қаралды 4,8 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Merge Two Sorted Lists - Leetcode 21 - Python
6:16
NeetCode
Рет қаралды 358 М.
LEETCODE 15 (JAVASCRIPT) | 3SUM
25:04
Andy Gala
Рет қаралды 6 М.
Violet Beauregarde Doll🫐
00:58
PIRANKA
Рет қаралды 50 МЛН