https://hack.codingblocks.com/practice/p/355/143
For this question how I can manuplate this Sum replacement code.
to get the answer,I tried in many ways but I failed to do so
int replaceSum(node*root){
if(root==NULL){
return 0;
}
if(root->left==NULL && root->right==NULL){
return root->data;
}
//Recursive Part
int leftSum = replaceSum(root->left);
int rightSum = replaceSum(root->right);
int temp = root->data;
root->data = leftSum + rightSum;
return temp + root->data;
}