been looking several videos of this problem. This is by far the best explaination video I have ever seen. Finally someone who can shove down information in my brain. Thank you
Is this Code is working in leetcode. It shows L3 statements at all cases getting error. L3 Statement is not a statement. Can anyone please help for this issue. Why it is coming
One of the best explanations I've seen. However, what is still throwing me off with LeetCode's solution was that they had l3 = head rather than head = l3 as you have here and I have been hung up on it for a while. I would appreciate it a lot if you could please help me understand why the order of the assignment doesn't seem to matter 🙏🙏🙏
thankew thankew thankew ! itna ache se samjhane ke liye. i was stuck in this problem because of the corner cases. Baaki videos se kuch khaas samaj nahi aya but with this video i got it all in one go! replay bhi nahi karna pada and i wrote it in java. once again thanking you🫂... bhagwan aapko ek world tour gift kar de meri taraf se🙏
thank you so much for this great explanation....I soled this problem in 3 different ways but some test cases didn't ran...When i saw ur explanation it was super easy...thanks a lot for this........
Arey wah. Maine bilkul aisa hi code likha tha java mein bus ye extra while loops nhi likhey they (when length of lists are not same) hmmm... Very nice explanation @Alisha Keep growing
Can you tell me how did you get so good at this? It feels like you know every step as soon as you read the question, although I am new to coding I am completely lost here...
Your explanation and all are fantastic but I would like to give you a feedback about try keeping your mic slightly away...it irritates sometimes. Thank you :)
So today, I was trying to add the numbers by storing in string and then reversing the string and what not and finally I cleared 1565 test cases failed 3. 😢😢
nice way of teaching i've done some new watching your logic var addTwoNumbers = function (l1, l2) { let node = new ListNode(0) let curr = node; let carry = 0; let sum = 0; while (l1 || l2 || carry) { if (!l2) { l2 = new ListNode(0) } if (!l1) { l1 = new ListNode(0) } sum = l1.val + l2.val + carry carry = Math.floor(sum / 10) let r = sum % 10 curr.next = new ListNode(r) curr = curr.next l1 = l1.next l2 = l2.next } // if(carry){ // curr.next=new ListNode(carry) // } return node.next };
You can avoid some code duplication by doing like this:
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode l3 = new ListNode(-1);
ListNode l3Head = l3;
int carry = 0;
while (l1 != null || l2 != null){
int l1Val = 0;
if (l1 != null) {
l1Val = l1.val;
l1 = l1.next;
}
int l2Val = 0;
if (l2 != null){
l2Val = l2.val;
l2 = l2.next;
}
int value = l1Val + l2Val + carry;
l3.next = new ListNode(value % 10);
carry = value / 10;
l3 = l3.next;
}
if (carry != 0){
l3.next = new ListNode(carry);
}
return l3Head.next;
}
in depth knowledge of how to solve a particular problem and how to take care of edge cases. Best explanation ever
really 😃 breaking down the problem into smaller chunks & solving every chunk 1 by 1 is the best thing of this channel.
I see many videos, but you explain very well. Best explanation and easy to understand.
been looking several videos of this problem. This is by far the best explaination video I have ever seen. Finally someone who can shove down information in my brain. Thank you
ListNode* l3 = new ListNode(0);
int carry =0;
ListNode* head = l3;
while(l1 && l2)
{
int value = l1->val+l2->val+carry;
carry = value/10;
l3->next = new ListNode(value%10);
l3 = l3->next;
l1 = l1->next;
l2 = l2->next;
}
while(l1)
{
int value = l1->val+carry;
carry = value/10;
l3->next = new ListNode(value%10);
l3 = l3->next;
l1 = l1->next;
}
while(l2)
{
int value = l2->val+carry;
carry = value/10;
l3->next = new ListNode(value%10);
l3 = l3->next;
l2 = l2->next;
}
if(carry)
{
l3 ->next = new ListNode(carry);
}
return head->next;
Is this Code is working in leetcode. It shows L3 statements at all cases getting error. L3 Statement is not a statement. Can anyone please help for this issue. Why it is coming
@@saijeswanth6673 if you working in java use ListNode l3 = new ListNode (0);
@@saijeswanth6673 class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode l3= new ListNode(0);
ListNode newhead=l3;
int carry=0;
while(l1!=null && l2!=null){
int result= l1.val+l2.val+carry;
carry=result/10;
l3.next= new ListNode(result%10);
l3=l3.next;
l1=l1.next;
l2=l2.next;
}
while(l1!=null){
int result= l1.val+carry;
carry=result/10;
l3.next= new ListNode(result%10);
l3=l3.next;
l1=l1.next;
}
while(l2!=null){
int result= l2.val+carry;
carry=result/10;
l3.next= new ListNode(result%10);
l3=l3.next;
l2=l2.next;
}
if(carry!=0){
l3.next= new ListNode(carry);
}
return newhead.next;
}
}
@@shubhamkate7849 can anyone explain why her code is not working
You explained it in student way thank you for the simple logic ! A lots of love
100 point for you. Love you very much for explain so eassy to understand
Ma'am, I'm working with java but I got complete logic of the code Hats off to you Ma'am
i started coding last few weeks.your viedoes was so helpful to me .thank you
so much clarity in your explanation, amazing
VERY GOOD EXPLANATION KEEP MORE MORE VIDEOS IN LEET CODE THANKS
Alish , your explaination is unparallel !!
it is such a nice and brief explanation
Gajab bhai mast samjhaya
One of the best explanations I've seen. However, what is still throwing me off with LeetCode's solution was that they had l3 = head rather than head = l3 as you have here and I have been hung up on it for a while. I would appreciate it a lot if you could please help me understand why the order of the assignment doesn't seem to matter 🙏🙏🙏
thankew thankew thankew ! itna ache se samjhane ke liye. i was stuck in this problem because of the corner cases. Baaki videos se kuch khaas samaj nahi aya but with this video i got it all in one go! replay bhi nahi karna pada and i wrote it in java. once again thanking you🫂... bhagwan aapko ek world tour gift kar de meri taraf se🙏
best explanation of this problem on yt. Very simple to understand .Kudos!
thank you so much for this great explanation....I soled this problem in 3 different ways but some test cases didn't ran...When i saw ur explanation it was super easy...thanks a lot for this........
just loved the way you explained....❤❤
Thank you so much Alisha, your code and explanation was so easy to understand.
You have no idea how confused I was in this..Thankyou for making this video
Nice Explanation, Keep it up
Whats d point of doing that if we r taking new list
It is advisable to do in same list without taking any extra space
Arey wah. Maine bilkul aisa hi code likha tha java mein bus ye extra while loops nhi likhey they (when length of lists are not same)
hmmm...
Very nice explanation @Alisha
Keep growing
Awesome! Keep practising Anshul !
but it is always recommended to do in constant space right ?
superb teaching skill
You know what you just gained one more subscriber😊😊 by the way thanks for the explanation
I don't why know but i am getting this error as :
error: not a statement
l3->next=new ListNode(value % 10);
^
can you help with this?
same bro
nice explaination Didi it really helps
Great Explanation
this is the first video on youtube that truly made me feel to subscribe. Thanks a lot.
Thank you so much Muhsin
ju ke ho kya ?
@@soumyadas900 haan 🥲
Can you tell me how did you get so good at this? It feels like you know every step as soon as you read the question, although I am new to coding I am completely lost here...
Thank you Didi...!!✨
How do you gain this logic to solve this kind of probs, let me know please, any tips to solve..
carry on sister.your explanation is better than any other explanation❤❤❤❤❤
Mam mera output wrong aa rha hai
I am begining to code and your video is helpful
Your explaination is soothing..keep going mam
very well explained di
Great explanation!!
Hey, can you just me how can I solve problem without getting errror. My solution is correct but keep saying error
can u make video on that.
same here - compilation error in line where we creating linklist
Nice mam. It was really good.😇😇
thanku so much di I understand 100 percent of your explanation with clarity because you explain so good keep it up di and help all
omg so much work put into this channel. thx for help and great work
amazing explaination
nice explaination
your explanation is so smooth and clear.thanks.
can you plz mention time complexity with your solution..it would be very useful.
your codes are really helpful
thanks
what is time and space complexity of this code?
Amazing explanation 😊 please make more videos
Very Good Video
Thanks a lot 👍👍👍
do it with recurrsion method because that is tricky
Last test case still not working!
Your explanation and all are fantastic but I would like to give you a feedback about try keeping your mic slightly away...it irritates sometimes.
Thank you :)
Best explanation
good explaination but please keep your speed slow we are just new in programming
perfect example of beauty with brain
Appreciated ❤
Thanks for the great explanation!
Thanks
Great explanation! please give time and space complexity too that would really help us all.
Thanks Great Logic
A hardstuck will always understand from you :D
Nice video,can i get the code?
vey nice explanation
Thanks Dear!
Thank you
Keep it up!!
great
your voice is so sweet and melodious
I didn't noticed the reverse word in the question and tried to solve this problem with wrong concept for three days
Thank you so much! Good explanation :)
clear!!
tq tq akka
good luck
mind blowing
i love you for this
Mam in this video you just look like's , just now woke up 😁😁
So today, I was trying to add the numbers by storing in string and then reversing the string and what not and finally I cleared 1565 test cases failed 3. 😢😢
I need all problems and java
thx
Where are you placed currently? Nice vid though
Microsoft
A beautiful girl with a beautiful explanation🙂🙂
The thing I've learnt is writing while(carry) exceeds time limit, so we write if(carry)..
Thank you ma'am for this kind explanation 😊😊
can u explain why it shows tle with while?
I wish you code in java also 😢
u deserve a subscribe
So cute 🥰
nice way of teaching i've done some new watching your logic
var addTwoNumbers = function (l1, l2) {
let node = new ListNode(0)
let curr = node;
let carry = 0;
let sum = 0;
while (l1 || l2 || carry) {
if (!l2) {
l2 = new ListNode(0)
}
if (!l1) {
l1 = new ListNode(0)
}
sum = l1.val + l2.val + carry
carry = Math.floor(sum / 10)
let r = sum % 10
curr.next = new ListNode(r)
curr = curr.next
l1 = l1.next
l2 = l2.next
}
// if(carry){
// curr.next=new ListNode(carry)
// }
return node.next
};
243+564=807 not 708
Sakal piche rakh kr bnaya jro
goodie
she's not explaining she's just practicing herself worse kind of explanation
Comeon man that was a fine explanation she cant teach u by grabbing your fingers
You think yourself genius , worst kind of explanation, please first learn to explain
nhi samaj aya, hindi me samghati to acha hota..kisi aur ki video dekhta hu
video play karte ho to cute sa face dikha tumara, pyar ho gya :)
//Java Code
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode l3 = new ListNode(0);
ListNode head = new ListNode();
head = l3;
int carry = 0;
while(l1!=null && l2!=null){
int value = l1.val+l2.val+carry;
carry = value/10;
l3.next = new ListNode(value%10);
l3 = l3.next;
l2 = l2.next;
l1 = l1.next;
}
while(l1!=null){
int value = l1.val+carry;
carry = value/10;
l3.next = new ListNode(value%10);
l3 = l3.next;
l1 = l1.next;
}
while(l2!=null){
int value = l2.val+carry;
carry = value/10;
l3.next = new ListNode(value%10);
l3 = l3.next;
l2 = l2.next;
}
if(carry>0){
l3.next = new ListNode(carry);
}
return head.next;
}
}
leetcode easy sol by me
class Solution {
private:
ListNode* reverse(ListNode* head) {
ListNode* curr = head;
ListNode* prev = NULL;
ListNode* next = NULL;
while(curr != NULL) {
next = curr -> next;
curr -> next = prev;
prev = curr;
curr = next;
}
return prev;
}
public:
ListNode* addTwoNumbers(ListNode* lis1, ListNode* lis2) {
ListNode*l1=reverse(lis1);
ListNode*l2=reverse(lis2);
ListNode*dummy=new ListNode();
ListNode*temp=dummy;
int carry=0;
while(l1!=NULL||l2!=NULL||carry){
int sum=0;
sum=sum+carry;
if(l1!=NULL){
sum+=l1->val;
l1=l1->next;}
if(l2!=NULL){
sum+=l2->val;
l2=l2->next;}
carry=sum/10;
ListNode* node=new ListNode(sum%10);sum+=carry;
temp->next=node;
temp=temp->next;
}temp=dummy;
ListNode*curr=reverse(temp->next);
return curr;
}
};
OP ma'am .. I'm getting u bit by bit every bit 🫡🔥