226. Invert Binary Tree
Description
Invert a binary tree.
Constraints
Approach
Links
GeeksforGeeks
ProgramCreek
YouTube
Examples
Input: [4, 2, 7, 1, 3, 6, 9]

Output: [4, 7, 2, 9, 6, 3, 1]

Solutions
// Definition for a binary tree node.
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode() {}
TreeNode(int val) {
this.val = val;
}
TreeNode(int val, TreeNode left, TreeNode right) {
this.val = val;
this.left = left;
this.right = right;
}
}
Follow up
Last updated
Was this helpful?