[LintCode] Invert Binary Tree
1 2 3 4 5 6 7 8 9 10 |
public void invertBinaryTree(TreeNode root) { // write your code here if(root == null) return; invertBinaryTree(root.left); invertBinaryTree(root.right); TreeNode left = root.left; root.left = root.right; root.right = left; } |
Leave A Comment