题解 | #链表中倒数第k个结点#
链表中倒数第k个结点
http://www.nowcoder.com/practice/529d3ae5a407492994ad2a246518148a
public ListNode FindKthToTail(ListNode head,int k) {
ListNode cur = head;
ListNode sign = head;
int count = 0;
while(cur != null){
count++;
cur = cur.next;
}
int n = count - k;
if(head == null || n < 0){
return null;
}
for(int i =0; i<n; i++){
sign = sign.next;
}
return sign;
}
}