Bro Just Covert it in Inorder easy solution


#1
void inor(TreeNode* root , vector<int>&ans)

{
if(root==NULL)
return;

 inor(root->left,ans);
 ans.push_back(root->val);
 inor(root->right,ans);

}
int Solution::kthsmallest(TreeNode* A, int B) {

vector<int>ans;

inor(A,ans);

return ans[B-1];

}