/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* findKthToTail(ListNode* pListHead, int k) {
int n = 0;
for (auto a = pListHead; a; a=a->next) {
++n;
}
if (n < k) {
return nullptr;
}
auto a = pListHead;
for (int i = 0; i < n - k; ++i) {
a = a->next;
}
return a;
}
};