I am getting correct output But not passing testcase

I am getting correct output But not passing testcase.

hi @Mihir163

mistakes

  1. you have to print in inorder traversal
  2. there is mistake in ranges
    preorderMOdified(root1->right,k2,k2);
    this should be preorderMOdified(root1->right,k1,k2);
  3. Print according to the question as directed
    cout<<"# Preorder : ";
    preorder(root);
    and then
    cout<<"# Nodes within range are : ";
    preorderMOdified(root,k1,k2);

i have corrected all mistake you can see in modified code

modified code

if your doubt is resolved Please mark it as resolved