/** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * this.left = this.right = null; * } * } */publicclassSolution { /** * @param root: The root of binary tree * @return: root of new tree */publicTreeNodecloneTree(TreeNode root) {if (root ==null) returnnull;TreeNode newNode =newTreeNode(root.val);newNode.left=cloneTree(root.left);newNode.right=cloneTree(root.right);return newNode; }}