clueless coding // TODO: be smarter

LeetCode Invert Binary Tree: Java Solution



TL;DR Code Solution


public TreeNode invertTree(TreeNode root) {

    if (root == null) {
        return root;
    }

    TreeNode temp = root.right;
    root.right = invertTree(root.left);
    root.left = invertTree(temp);

    return root;

}