Problem Statement
Pattern:
Solution
public Node invertTree (Node root){
if(root == null) return null;
// swap
Node temp = root.left;
root.left = root.right;
root.right = temp;
invertTree(root.left);
invertTree(root.right);
return root;
}
Notes
- self explanatory