Solution using resursion


#1

void inorder(TreeNode* A,int B,int C,int &res)
{
if(A==NULL)
return;
inorder(A->left,B,C,res);
if(A->val>=B && A->val<=C)
res++;
inorder(A->right,B,C,res);
}
int Solution::solve(TreeNode* A, int B, int C) {
int res=0;
inorder(A,B,C,res);
return res;
}