Java dfs clean code

  • 0
    public TreeNode invertTree(TreeNode root) {
        return helper(root);
    private TreeNode helper(TreeNode root){
            return null;
        TreeNode left = helper(root.left);
        TreeNode right = helper(root.right);
        root.left = right;
        root.right = left;
        return root;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.