LeetCode 刷题记录: 19. Remove Nth Node From End of List [Python]

原题

https://leetcode.com/problems/remove-nth-node-from-end-of-list/

Given a linked list, remove the n-th node from the end of list and return its head.

Follow up:

Could you do this in one pass?

思路

使用两个指针fast以及slow,fast先出发,slow相隔n位再出发。当fast走到尽头时slow跳过下一指针即可。

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×