Sword 22

https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/

返回链表的倒数第 k个节点

常规做法要遍历最多两遍链表,而现在我们只需要遍历一遍

先让 t 走 K 个节点使得长度固定住(即 h 与 t 最终距离为 K)

再让 h, t 一起走到尾部即为所得

原文地址:https://www.cnblogs.com/FriskyPuppy/p/14527990.html