Isse simple nhi milega bhai log


#1

void sol(TreeNode A,int &B,int &ans)
{
if(A==NULL)
return;
sol(A->left,B,ans);
B–;
if(B==0)
ans = A->val;
sol(A->right,B,ans);
}
int Solution::kthsmallest(TreeNode
A, int B) {
int ans;
sol(A,B,ans);
return ans;
}