Skip to content

Commit 4712af7

Browse files
author
Thuy Trinh
committed
Add README
1 parent 4d3ddd2 commit 4712af7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -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+
1
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

Comments
 (0)