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 91b14d3 commit 8b0f153Copy full SHA for 8b0f153
src/task_226/Solution.java
@@ -0,0 +1,17 @@
1
+package task_226;
2
+
3
+public class Solution {
4
5
+ public TreeNode invertTree(TreeNode root) {
6
+ if (root == null) {
7
+ return null;
8
+ }
9
+ invertTree(root.left);
10
+ invertTree(root.right);
11
+ TreeNode tmp = root.left;
12
+ root.left = root.right;
13
+ root.right = tmp;
14
+ return root;
15
16
17
+}
src/task_226/TreeNode.java
@@ -0,0 +1,21 @@
+/** 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.left = left;
18
+ this.right = right;
19
20
21
0 commit comments