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......
@donghunpark3794 жыл бұрын
I think your code could not solve the below case. Isn't it? [1,2] 2 Expected Output : [2]
@daneaflek5 жыл бұрын
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.
@jingyang69487 жыл бұрын
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
@ShantanuRajeNimbalkar6 жыл бұрын
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?
@paulmadeya53966 жыл бұрын
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?
@vipuljindal16605 жыл бұрын
This does not cover the case if n is greater than the length of the list
@10OzGlove6 жыл бұрын
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)...
@rahatkumar46647 жыл бұрын
Well Understood. Thanks Sir
@yueranzhang23505 жыл бұрын
for(int i =0;i
@MiddleEasternInAmerica5 жыл бұрын
hope you get the opportunity to make more videos.
@NilesMac24 жыл бұрын
thank you for explaining what slow.next.next means! Everyone skips over it and I wasn't understanding.
@SauravKumar-rk6dr5 жыл бұрын
made me to understand so easily...thank you
@Detros126 жыл бұрын
Great explanation ^.^
@MrSaiyah0074 жыл бұрын
Wrong animation. Wrong solution. When you are explaining about n = 2, then why are you showing animation for n = 3 removal. So confusing.