JZ14 链表中倒数第k个结点 C++
class Solution {
public:ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) {if(!pListHead || k <&#61; 0) return NULL;ListNode *p &#61; pListHead, *q &#61; pListHead;while(k > 0) {q &#61; q->next;k--;if(!q && k) return NULL;}while(q) {p &#61; p->next;q &#61; q->next;}return p;}
};