Skip to content

Commit cf586be

Browse files
authored
Update maximum-score-after-applying-operations-on-a-tree.cpp
1 parent 5e7c5fa commit cf586be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

C++/maximum-score-after-applying-operations-on-a-tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Solution {
1616
while (!empty(stk)) {
1717
const auto [step, u, p] = stk.back(); stk.pop_back();
1818
if (step == 1) {
19-
if (u && size(adj[u]) == 1) {
19+
if (size(adj[u]) == (u ? 1 : 0)) {
2020
dp[u] = static_cast<int64_t>(values[u]);
2121
continue;
2222
}
@@ -55,7 +55,7 @@ class Solution2 {
5555
adj[e[1]].emplace_back(e[0]);
5656
}
5757
const function<int64_t (int, int)> dfs = [&](int u, int p) {
58-
if (u && size(adj[u]) == 1) {
58+
if (size(adj[u]) == (u ? 1 : 0)) {
5959
return static_cast<int64_t>(values[u]);
6060
}
6161
int64_t total = 0;

0 commit comments

Comments
 (0)