function KthNode( proot ,  k ) {
    if(proot===null) return -1;
    // write code here
    let arr = [];
    function search(root,arr){
        if(!root) return;
        arr.push(root.val);
        search(root.left,arr);
        search(root.right,arr);
        return arr;
    }
    arr = search(proot,arr);
    function comp(a,b){
        return a-b;
    }
    let newarr = arr.sort(comp);
    if(k>newarr.length || k===0) return -1;
    return newarr[k-1];
}
module.exports = {
    KthNode : KthNode
};