Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4da9264

Browse files
committed
tree
1 parent fdfa05e commit 4da9264

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Solution {
2+
3+
def transfer(root: TreeNode, base: Int = 0): Int = {
4+
if (root == null) base
5+
else{
6+
root.value += transfer(root.right, base)
7+
transfer(root.left, root.value)
8+
}
9+
}
10+
11+
def bstToGst(root: TreeNode): TreeNode = {
12+
transfer(root)
13+
root
14+
}
15+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /