Skip to content

Commit 334288d

Browse files
committed
Runtime: 0 ms (Top 100.00%) | Memory: 8.2 MB (Top 56.00%)
1 parent afa53ba commit 334288d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
// Runtime: 0 ms (Top 100.00%) | Memory: 8.2 MB (Top 56.00%)
12
class Solution {
23
public:
3-
4+
45
int s = 0;
5-
6+
67
void solve(TreeNode* root){
78
if(!root) return;
89
solve(root->right);
9-
10+
1011
root->val = s + root->val;
1112
s = root->val;
12-
13+
1314
solve(root->left);
1415
return;
1516
}
16-
17+
1718
TreeNode* bstToGst(TreeNode* root) {
1819
if(!root) return NULL;
1920
solve(root);
2021
return root;
2122
}
22-
};
23+
};

0 commit comments

Comments
 (0)