LeetCode – Invert Binary Tree (Java)
Java Solution 1 – Recursive public TreeNode invertTree(TreeNode root) { helper(root); return root; } public void helper(TreeNode n){ if(n==null){ return; } TreeNode t = n.left; n.left = n.right; n.right = t; helper(n.left); helper(n.right); }public TreeNode invertTree(TreeNode root) { helper(root); return root; } public void helper(TreeNode n){ if(n==null){ return; } TreeNode t = … Read more