Skip to content

Commit a885b20

Browse files
committed
add 114
1 parent 90ca28a commit a885b20

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

medium/114-flatten-binary-tree.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
private TreeNode prev = null;
3+
4+
public void flatten(TreeNode root) {
5+
if (root == null) {
6+
return;
7+
}
8+
flatten(root.right);
9+
flatten(root.left);
10+
root.right = prev;
11+
root.left = null;
12+
prev = root;
13+
}
14+
}

0 commit comments

Comments
 (0)