226. Invert Binary Tree
class Solution {
public TreeNode invertTree(TreeNode root) {
if (root ==null) return null;
TreeNode temp=root.right;
root.right=root.left;
root.left = temp;
invertTree(root.left);
invertTree(root.right);
return root;
}
}
Last updated
Was this helpful?