# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None classSolution: defFindKthToTail(self, head, k): # 快慢指针,快指针先走 if k == 0or head isNone: returnNone fast = head slow = head for i in range(0, k-1): fast = fast.next if fast isNone: returnNone while fast.next isnotNone: fast = fast.next slow = slow.next return slow