快慢指针

快指针先往前走k步,注意判断边界,然后快慢一起走,当快指针为none的时候,慢指针走到了倒数第k个节点

class Solution:
    def FindKthToTail(self, head, k):
        # write code here
        slow,fast=head,head
        for i in range(k):
            if not fast:
                return None
            fast=fast.next
        while fast:
            slow=slow.next
            fast=fast.next
        return slow