Add Two Numbers Given as LinkedLists | Amazon | Microsoft | Facebook | Qualcomm

preview_player
Показать описание

In case you are thinking to buy courses, please check below:

#dsa #leetcode #placements
Рекомендации по теме
Комментарии
Автор

that's the tip, don't let interviewer know that u have already solved the problem. 😂

ankitr
Автор

I was asked this question in my interview with Amazon.
Great work, Raj bhaiya!

GeekyBaller
Автор

your way of teaching is very simple, and easy to understand

avishekroy
Автор

Great placement series is hitting bro just watching everytime i open youtube.

mrinmoyaus
Автор

#code in python
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def addTwoNumbers(self, A: Optional[ListNode], B: Optional[ListNode]) -> Optional[ListNode]:
l3=ListNode(0)
head=l3
carry=0
while A or B or carry:
if A:
carry += A.val
A=A.next
if B:
carry += B.val
B=B.next
l3.val=carry%10
carry=carry//10
if A or B or carry:
l3.next=ListNode(0)
l3=l3.next
return head

settyruthvik
Автор

I wanted to send you a heartfelt thank you for your tireless dedication to teaching DSA for free. Your selflessness and passion for helping students with their job interview preparation have made a significant impact on my life and countless others. I am incredibly grateful for the knowledge and confidence you have imparted to us. Thank you for everything you do!❣✨✨

abhay
Автор

i was solving this question on leetcode and the logic hit me in just 2mins but i wasn't able to code it

prabaljain
Автор

we can also do like while(l1!=null || l2!=null) and after loop we can check if carry>0 then make a node else dont make

DeepakGupta-zzvf
Автор

I solved this without any extra space, making the additions in the node itself, was a bit complicated but yet it worked !

tanishq
Автор

You are amazing best programming teacher on youtube keep it up brother

avadheshsingh
Автор

You are really amazing at explaining every concept clearly

reallydarkmatter
Автор

Thank you bro..
For uploading multiple videos in a single day..

NagaVijayKumar
Автор

I was able to do this in O(1) space as well with some optimisation (adding the sum values in the given listnodes only). Wouldn't that be a better answer to give to an interviewer?

Metalrave
Автор

Striver You are GREAT Love from West Bengal <3

hrishitsarkar
Автор

Nicely put explanation (as always) for "how to add two numbers given as Linked Lists". Thanks bro.

hemanthvarmas
Автор

Finally a question i figured out myself😂

dhruvrajput
Автор

Love your simple and clean explanation 💯💯📸

gamingwithhemend
Автор

It was a really awesome explanation if you don't mind can you make a video on " k Queues in a single array " and " k Stack in a single array " when you START WITH STACK and QUEUE because I am not able to understand these two questions.

techdemy
Автор

Why do we need the dummy node in the starting why can't directly start from first sum value?

SudhanshuKumar-lpnr
Автор

Nice and clear explanation. One question... Should we consider the space used by output list when calculating space complexity?

jatinkumar