LeetCode 226. Invert Binary Tree Posted on 2021-08-03 In Leetcode , Tree Symbols count in article: 427 Reading time ≈ 1 mins. QuestionGiven the root of a binary tree, invert the tree, and return its root. https://leetcode.com/problems/invert-binary-tree/ Solution Solution1 1234567891011121314class Solution { public TreeNode invertTree(TreeNode root) { if(null == root){ return null; } TreeNode left = invertTree(root.left); TreeNode right = invertTree(root.right); root.left = right; root.right = left; return root; }} Complexity: Time complexity: O(n) Space complexity: O(h) Post author: MrainW Post link: https://mrainw.github.io/2021/08/03/LeetCode 226. Invert Binary Tree/ Copyright Notice: All articles in this blog are licensed under BY-NC-SA unless stating additionally. Welcome to my other publishing channels WeChat