We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fddbef5 commit 0bb77e5Copy full SHA for 0bb77e5
invert-binary-tree/ekgns33.java
@@ -0,0 +1,25 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * public class TreeNode {
4
+ * int val;
5
+ * TreeNode left;
6
+ * TreeNode right;
7
+ * TreeNode() {}
8
+ * TreeNode(int val) { this.val = val; }
9
+ * TreeNode(int val, TreeNode left, TreeNode right) {
10
+ * this.val = val;
11
+ * this.left = left;
12
+ * this.right = right;
13
+ * }
14
15
+ */
16
+class Solution {
17
+ public TreeNode invertTree(TreeNode root) {
18
+ if(root == null) return null;
19
+ TreeNode left = invertTree(root.left);
20
+ TreeNode right = invertTree(root.right);
21
+ root.right = left;
22
+ root.left =right;
23
+ return root;
24
+ }
25
+}
0 commit comments