链表的倒数第k个节点
2019-12-21 本文已影响0人
而立之年的技术控
微信图片_20191221162931.jpg
class Solution:
def FindKthToTail(self, head, k):
# write code here
if head is None:
return None
first = head
second = head
for _ in range(k):
if first == None:
return None
first = first.next
while first != None:
first = first.next
second = second.next
return second