题目描述
输入一个链表,输出该链表中倒数第k个结点。
无力吐槽牛客网。。。
1 class Solution: 2 def FindKthToTail(self, head, k): 3 # write code here 4 f=p=head 5 while f and k>0: 6 f=f.next 7 k-=1 8 if k>0 and f==None: 9 return 10 while f!=None: 11 p=p.next 12 f=f.next 13 return p
2019-12-06 11:12:54