19. Remove Nth Node From End of List
Problem
Given a linked list, remove the node from the end of list and return its head.
For example
Note: Given n will always be valid. Try to do this in one pass.
Related Topics:
Linked List
Two Pointers
Analysis
设置两个点,其间隔为 n
,之后同步移动点 front
与 back
,当 front
到达末尾时,back
正好达到操作位置。
Code
Last updated