@@ -28,21 +28,21 @@ class Solution {
28
28
const auto & total = lsum + node->val + rsum;
29
29
result = max (result, total);
30
30
*ret = {true , total, min (lmin, node->val ), max (node->val , rmax)};
31
- } else {
32
- *ret = {false , 0 , 0 , 0 };
33
- }
34
- } else {
35
- if (!node) {
36
- *ret = {true , 0 ,
37
- numeric_limits<int >::max (),
38
- numeric_limits<int >::min ()};
39
31
continue ;
40
32
}
41
- const auto & tmp = make_shared<vector<RET>>(2 );
42
- stk.emplace_back (node, tmp, ret);
43
- stk.emplace_back (node->right , nullptr , &((*tmp)[1 ]));
44
- stk.emplace_back (node->left , nullptr , &((*tmp)[0 ]));
33
+ *ret = {false , 0 , 0 , 0 };
34
+ continue ;
35
+ }
36
+ if (!node) {
37
+ *ret = {true , 0 ,
38
+ numeric_limits<int >::max (),
39
+ numeric_limits<int >::min ()};
40
+ continue ;
45
41
}
42
+ const auto & new_tmp = make_shared<vector<RET>>(2 );
43
+ stk.emplace_back (node, new_tmp, ret);
44
+ stk.emplace_back (node->right , nullptr , &((*new_tmp)[1 ]));
45
+ stk.emplace_back (node->left , nullptr , &((*new_tmp)[0 ]));
46
46
}
47
47
return result;
48
48
}
0 commit comments