Тёмный

Google Coding Interview Question: Remove Nth Node From End of Linked List 

Stephen O'Neill
Подписаться 4,6 тыс.
Просмотров 8 тыс.
50% 1

Remove Nth Node From End of Linked List and a java example.
Let me know what I can do better and what else you want me to cover.
Give it a like if it helped you and subscribe!!
All code can be found here:
github.com/one...
ONeill Code's purpose is to provide in-depth tutorials on a wide range of programming material. It can focus on interview questions or simple algorithms depending on the user requests. If you have any video requests please let me!

Опубликовано:

 

20 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@jeesan2006
@jeesan2006 4 года назад
There is small problem with this....... one test case if the LL is [1,2] and n = 2, it will fail, return head.next in the for loop if fast is null and make the condition ;i < n+1;.............Else it is a great explanation.....thank you for the video......
@donghunpark379
@donghunpark379 4 года назад
I think your code could not solve the below case. Isn't it? [1,2] 2 Expected Output : [2]
@jingyang6948
@jingyang6948 7 лет назад
LinkedList = 1->2->3->4->5, n=5. Result should be 2->3->4->5, while your code returns 1->2->3->4->5. At line 24, change i
@ShantanuRajeNimbalkar
@ShantanuRajeNimbalkar 6 лет назад
Does this take care of the case when the element to be deleted is the 1st element in the linked list? In such a case we would have to change the head also right?
@daneaflek
@daneaflek 4 года назад
It does not remove the very first node, means in your example of 7 nodes, if i give n = 6, ( as index starts from 0) it does not remove, instead prints complete list as it is.
@paulmadeya5396
@paulmadeya5396 5 лет назад
Isn’t the node you are removing in the brute force example should be 6 and not 7? N is 2 meaning it’s the second node from the end. Can you clarify this?
@rahatkumar4664
@rahatkumar4664 7 лет назад
Well Understood. Thanks Sir
@SauravKumar-rk6dr
@SauravKumar-rk6dr 5 лет назад
made me to understand so easily...thank you
@NilesMac2
@NilesMac2 4 года назад
thank you for explaining what slow.next.next means! Everyone skips over it and I wasn't understanding.
@MiddleEasternInAmerica
@MiddleEasternInAmerica 4 года назад
hope you get the opportunity to make more videos.
@10OzGlove
@10OzGlove 6 лет назад
I don't understand why 2 pointers if more efficient. You calculated the number of interations based on the number of times a node's next() method is called, so it's the same? Why calling fastPointer.next() and slowPointer.next() is only counted as one iteration? You say these moves happen at the same time, but not in the code. I'm confused. To me their complexity is big O(n)...
@yueranzhang2350
@yueranzhang2350 5 лет назад
for(int i =0;i
@vipuljindal1660
@vipuljindal1660 5 лет назад
This does not cover the case if n is greater than the length of the list
@Detros12
@Detros12 6 лет назад
Great explanation ^.^
@MrSaiyah007
@MrSaiyah007 4 года назад
Wrong animation. Wrong solution. When you are explaining about n = 2, then why are you showing animation for n = 3 removal. So confusing.
Далее
Merge Sort step by step walkthrough (Recursion)
7:29
Шок-контент! 😱
00:50
Просмотров 1,3 млн
aespa 에스파 'Whiplash' MV
03:11
Просмотров 7 млн
Watching This On Loop ♾️
00:32
Просмотров 9 млн
8 Data Structures Every Programmer Should Know
17:09
Просмотров 120 тыс.
Merge Two Sorted Lists
8:53
Просмотров 85 тыс.
Шок-контент! 😱
00:50
Просмотров 1,3 млн