* struct ListNode {
 *	int val;
 *	struct ListNode *next;
 *	ListNode(int x) : val(x), next(nullptr) {}
 * };
 */
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param pHead ListNode类 
     * @param k int整型 
     * @return ListNode类
     */
    ListNode* FindKthToTail(ListNode* pHead, int k) {
        int len=1;
        ListNode *p=pHead;
        ListNode *s=NULL;
        if(pHead==NULL){
            return NULL;
        }
        while(p->next!=NULL){
            p=p->next;
            len+=1;
        }
        p=pHead;
        int count=1;
        if(len<k){
            return NULL;
        }
        else{
            while(p->next!=NULL){
            if(count==len-k+1){
                s=p;
            }
                count+=1;
                p=p->next;
            }
            return s;
        }
        // write code here
    }
};