C# recursion, easy and stupid


  • 0
    D
    public class Solution {
        public TreeNode InvertTree(TreeNode root) {
            if (root == null){
                return null;
            }
            TreeNode b = root.left;
            root.left = root.right;
            root.right = b;
            InvertTree(root.left);
            InvertTree(root.right);
            return root;   
        }
    }

Log in to reply
 

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