diff --git "a/leetcode3/\354\227\274\355\230\234\354\240\225/226. Invert Binary Tree.java" "b/leetcode3/\354\227\274\355\230\234\354\240\225/226. Invert Binary Tree.java" new file mode 100644 index 000000000..be86acc83 --- /dev/null +++ "b/leetcode3/\354\227\274\355\230\234\354\240\225/226. Invert Binary Tree.java" @@ -0,0 +1,15 @@ +// O(n) + +class Solution { + public TreeNode invertTree(TreeNode root) { + if (root == null) return null; + + TreeNode temp = root.left; + root.left = root.right; + root.right = temp; + + invertTree(root.left); + invertTree(root.right); + return root; + } +}