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

  Рет қаралды 7,974

Stephen O'Neill

Stephen O'Neill

Күн бұрын

Пікірлер: 15
@jeesan2006
@jeesan2006 5 жыл бұрын
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]
@daneaflek
@daneaflek 5 жыл бұрын
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.
@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?
@paulmadeya5396
@paulmadeya5396 6 жыл бұрын
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?
@vipuljindal1660
@vipuljindal1660 5 жыл бұрын
This does not cover the case if n is greater than the length of the list
@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)...
@rahatkumar4664
@rahatkumar4664 7 жыл бұрын
Well Understood. Thanks Sir
@yueranzhang2350
@yueranzhang2350 5 жыл бұрын
for(int i =0;i
@MiddleEasternInAmerica
@MiddleEasternInAmerica 5 жыл бұрын
hope you get the opportunity to make more videos.
@NilesMac2
@NilesMac2 4 жыл бұрын
thank you for explaining what slow.next.next means! Everyone skips over it and I wasn't understanding.
@SauravKumar-rk6dr
@SauravKumar-rk6dr 5 жыл бұрын
made me to understand so easily...thank you
@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
Stephen O'Neill
Рет қаралды 99 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
L8. Remove Nth Node from the end of the LinkedList | Multiple Approaches
16:23
Delete Nth Node From Last In Linked List
10:33
CppNuts
Рет қаралды 1,8 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 681 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
The Dark Side of .reserve()
18:50
Logan Smith
Рет қаралды 178 М.
Introduction to Linked Lists (Data Structures & Algorithms #5)
18:47
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН