Invert Binary Tree LeetCode solution in Python
1# Runtime: 7 ms (Top 98.3%) | Memory: 13.26 MB (Top 67.3%)234class Solution(object):5def invertTree(self, root):6# Base case...7if root == None:8return root9# swapping process...10root.left, root.right = root.right, root.left11# Call the function recursively for the left subtree...12self.invertTree(root.left)13# Call the function recursively for the right subtree...14self.invertTree(root.right)15return root # Return the root...