Not Passing one test case plss help

#include
#include
using namespace std;
class Node
{
public:
int data;
Node *left;
Node *right;
Node(int d)
{
data = d;
left = NULL;
right = NULL;
}
};
void create(Node *&root)
{
int d;
cin >> d;
root = new Node(d);
string left1, right1;
cin >> left1;
if (left1 == “true”)
{
create(root->left);
}
cin >> right1;
if (right1 == “true”)
{
create(root->right);
}
}
void printPathUtils(Node *root, int sum, int sumsofar, vector &path)
{
if (root == NULL)
{
return;
}
sumsofar += root->data;
path.push_back(root->data);
if (sumsofar == sum)
{
for (int i = 0; i < path.size(); i++)
{
cout << path[i] << " ";
}
}
if (root->left != NULL)
{
printPathUtils(root->left, sum, sumsofar, path);
}
if (root->right != NULL)
{
printPathUtils(root->right, sum, sumsofar, path);
}
path.pop_back();
}
int main()
{
Node *root=nullptr;
create(root);
int sum;
cin>>sum;
vector path;
printPathUtils(root,sum,0,path);
return 0;
}

hi @guptaharish93_ea50700f6731bd2b
after printing each path give a new line (ie endl)
corrected code -->

hi @guptaharish93_ea50700f6731bd2b
i hope its clear now??

it still isnt passing testcase number 2 @Vaibhav277

hi @guptaharish93_ea50700f6731bd2b
ur code is absolutely fine… its compiler issue… in ques its mentioned to print all paths but in test cases, only one path is being accepted so don’t worry ur code is fine… u can move ahead with other questions…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.