We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4d3ddd2 commit 4712af7Copy full SHA for 4712af7
src/main/java/leetcode/flattenbtree/README.md
@@ -0,0 +1,26 @@
1
+```
2
+ 1
3
+ / \
4
+2 3
5
6
+
7
+* Temporarily hold `3`.
8
+* Change `1`'s right tree into `2`. Clear `1`'s left tree.
9
+* Change `2`'s right tree into `3`. Clear `2`'s left tree.
10
11
12
13
14
+ 2 3
15
+ / /
16
+4 6
17
18
19
+* Flatten the subtree `2`.
20
+* Flatten the subtree `3`.
21
+* Temporarily hold root of the subtree `3`.
22
+* Change `1`'s right tree into root of the subtree `2`. Clear `1`'s left tree.
23
+* Get last node of the subtree `2`. Change the right node of this last node into root of the subtree `3`.
24
+* Return last node of the flattened left subtree `2` if any.
25
+* Return last node of the flattened right subtree `3` if any.
26
+* Otherwise, return `1`.
0 commit comments