经过启发的代码:
class Solution { public: ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) { if (pListHead==NULL) return pListHead; if(k==0) return NULL; ListNode* p1 = pListHead; ListNode* p2 = pListHead; unsigned int n = 1; while(p2->next !=NULL) { if(n < k) { n++; } else if(n == k) { p1 = p1->next; } p2 = p2->next; } if(n < k) return NULL; return p1; } };