What's wrong in this?


#1
 void inorder(TreeNode *root,vector<int> &v){
    if(root==NULL) return;
    inorder(root->left,v);
    v.push_back(root->val);
    inorder(root->right,v);
    
}
int Solution::kthsmallest(TreeNode* A, int B) {
    vector<int> v;
    inorder(A,v);
    return v[B-1];
}

#2

You don’t have to iterate through the entire tree.