Easiest CPP solution....have a look


#1

void traverse(vector &v,TreeNode* p)
{
if(p==NULL)
return;

traverse(v,p->left);
v.push_back(p->val);
traverse(v,p->right);

}
int Solution::kthsmallest(TreeNode* A, int B) {
vector v;
traverse(v,A);
return v[B-1];
}