In fact, it is not clear to do so in the end can not, then it becomes. .
Ideas like or thorough enough, there is a vague point, and did not fully grasp.
Although it is doing the right thing, but not necessarily the next time, or if then a little more complicated, but probably not. . . .
class Solution: def invertTree(self, root: TreeNode) -> TreeNode: if not root: return root def helper(node): if node: if node.left or node.right: node.left,node.right=node.right,node.left helper(node.left) helper(node.right) helper(root) return root
When execution: 48 ms, beat the 47.66% of users in all python3 submission
Memory consumption: 13.9 MB, beat the 5.24% of users in all python3 submission
——2019.11.19