/*
public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}*/
import java.util.Stack;
public class Solution {
    public ListNode FindKthToTail(ListNode head,int k) {
        if(head==null || k<=0)
            return null;
        Stack<ListNode> stack=new Stack<>();
        while (head!=null){
            stack.push(head);
            head=head.next;
        }
        if (stack.size()<k){
            return null;
        }
        int i=1;
        ListNode listNode=null;
        while (i<=k && !stack.isEmpty()){
            listNode=stack.pop();
            i++;
        }
        return listNode;
    }
}