快慢指针法
func kthToLast(head *ListNode, k int) int {
q := head
s := head
for i:=0;i<k;i++{
q = q.Next
}
for q!=nil{
q = q.Next
s = s.Next
}
return s.Val
}
快慢指针法
func kthToLast(head *ListNode, k int) int {
q := head
s := head
for i:=0;i<k;i++{
q = q.Next
}
for q!=nil{
q = q.Next
s = s.Next
}
return s.Val
}