[编程题]链表中倒数第k个结点
链表中倒数第k个结点
http://www.nowcoder.com/questionTerminal/529d3ae5a407492994ad2a246518148a
public class Solution {
public ListNode FindKthToTail(ListNode head, int k) {
ListNode res = head;
int index = 0;
while(head != null){
if(index == k){
res = res.next;
}
else{
index++;
}
head = head.next;
}
if(index < k)
return null;
return res;
}
}
360集团公司福利 394人发布