Any suggestions on reducing the memory use? Appreciate your time!

public class Solution {

public TreeNode buildTree(int[] inorder, int[] postorder) {

if(inorder.length!=postorder.length||inorder.length==0) return null;

int length=inorder.length;

return build(inorder,postorder,0,length-1,length-1);

}

```
public TreeNode build(int[] inorder,int[] postorder,int start,int end,int postIndex){
if(start>end) return null;
int inorderIndex=0;
while(inorder[inorderIndex]!=postorder[postIndex])
inorderIndex++;
int leftNum=inorderIndex-start;
int rightNum=end-inorderIndex;
TreeNode root=new TreeNode(postorder[postIndex]);
root.left=build(inorder,postorder,start,inorderIndex-1,postIndex-rightNum-1);
root.right=build(inorder,postorder,inorderIndex+1,end,postIndex-1);
return root;
}
```

}