题目描述
blablabla
样例
blablabla
算法1
(一次遍历) $O(n)$
blablabla
时间复杂度O(n)
参考文献
python 代码
class Solution(object):
def findKthToTail(self, pListHead, k):
if not pListHead:
return None
fast= pListHead
slow = pListHead
if k>0:
for i in range(k):
#注意,判断条件要提前
if not fast:
return None
fast = fast.next
while fast:
slow = slow.next
fast = fast.next
return slow