Remove nth node from end of Linked List (LeetCode 19) | A very very easy solution

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

Chapters:
00:00 - Intro
00:41 - Problem Statement
02:26 - Why is it a medium difficulty?
04:30 - Number theory trick
07:19 - Handling special cases
10:40 - Dry-run of Code
13:41 - Final Thoughts

📚 Links to topics I talk about in the video:

📖 Reference Books:

🎥 My Recording Gear:

💻 Get Social 💻

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

GOATED Channel for me !! Best Playlist for DSA Problems

saisanjan
Автор

This channel is a gem. Thanks Nikhil for the wonderful explanation.

sachinsoma
Автор

Best explanation for the solution, neetcode doesnt come close at all.

sreeharsharaveendra
Автор

i saw 2videos previously explaining the solution but didnt understood at you so much for making us understand in a very very simple way

Humanityplease
Автор

What I like about your videos is how you explain the brute force approach first and then explain the optimised solution. Introducing brute force solutions to noobs like me gives us some confidence and with that confidence + your simplicity of explaining the optimised solution works like charm, baba Beautiful! I also like how the structure is consistent across every video that you upload. Keep rising Nikhil🚀

AadeshKulkarni
Автор

Wow! Brilliant explanation! You have helped me to finally demystify the fear around coding algorithm.

tundeadebanjo
Автор

Non forgettable explanation ...! Excellent

jaydeepvasoya
Автор

Your way of explanation!!! Thank you so much.

Muhammad_Kabil
Автор

Such amazing content!! These videos are so well done. Thank you

robertnant
Автор

Great explanation👍 . For removing nth from start, we can simply iterate (n-1)th node and map n-1 -> n+1. TC : O(n) and SC : O(1)

shivraj
Автор

great explanation bro. Thanks for the video

wilberrosales
Автор

Thank you Nikhil bhai, you helped me a lot with linkedlist problems.

atanukundu_
Автор

great explanation you are doing great keep going

uxoyplayz
Автор

Bro this code is very help full in LeetCode it shows error , In the for Loop (i<=n ) not (i<n), Correct me if i am wrong . But thaks for your vidoes

kash
Автор

at 9:20 we just have one node, so n should be n=0 . If n=1 then we will have exception . while n=1, you are removing 8 not 4 in the previous example.

lookahead
Автор

Make an Adjustment to the code in while moving the secondPtr... set the limits of the for loop to be from i=1 to i<=n+1 and increment i by 1... you ain't gonna get any error thank me latter...

Pontiff
Автор

@nikhi if not the case of just one traveal can i reverse the linked list and delete it from the first and return the new linkedlist ?

naveenkumarkota
Автор

Thank you for explaining. Can you please start a playlist of solving leetcode 75. It would be very helpfulto us.

srinivas
Автор

// without dummy node
class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n) {
ListNode*start=head;
ListNode*end=head;
while(n--)
{
end=end->next;
}
if(end==NULL)return head->next;
while(end->next!=NULL)
{
start=start->next;
end=end->next;
}

return head;
}
};

himanshusingh
Автор

Nice explanation sir 👍. Can we store all the pointers in a arraylist and storing its length in one ireration and mapping pointer of that index(len-n) to its next.
Is that approach correct sir??

Karthik-flcq