/**
* 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) {
stack<ListNode*> s;
int length=0;
for(auto p=pListHead;p;p=p->next)
{
s.push(p);
length++;
}
if(k>length)
{
return NULL;
}
while(k>1)
{
s.pop();
k--;
}
auto t=s.top();
return t;
}
};