All test are fail but my code compile time work fine

import java.util.*;
public class Main {
private class Node{
Node left;
Node right;
int data;
}
private Node root;
void constract(int ar[]){
this.root=constract(ar,0,ar.length);
}
private Node constract(int ar[],int low,int high) {
if(low>=high)
{
return null;
}
int mid=(low + high)/2;
Node nn=new Node();
nn.data=ar[mid];
nn.left=constract(ar,low,mid);
nn.right=constract(ar,mid+1,high);
return nn;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int ar[]=new int [n];
for(int i=0;i<n;i++) {
ar[i]=sc.nextInt();
}
Main tree=new Main();
tree.constract(ar);
//tree.preOrder();
tree.replaceWithSum();
// System.out.println();
tree.preOrder();

}

public void replaceWithSum(){
replaceWithSum(this.root);
}
static int sum=0;
private void replaceWithSum(Node node) {
if(node==null) {
return ;
}
replaceWithSum(node.right);
sum+=node.data;
node.data=sum;
replaceWithSum(node.left);
}
public void preOrder() {
preOrder(this.root);
}

private void preOrder(Node node) {
if(node==null) {
return ;
}
System.out.print(node.data+" ");
preOrder(node.left);
preOrder(node.right);

}

}

@sksumitkumardiwaker,
https://ide.codingblocks.com/s/231777 corrected code.

There were small errors in your construct method. I have added comments on the lines that were wrong for your reference.

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.