Skip to content

Commit ec0bd53

Browse files
committed
Time: 14 ms (51.70%), Space: 15.2 MB (49.47%) - LeetHub
1 parent ff5e9be commit ec0bd53

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

0590-n-ary-tree-postorder-traversal/0590-n-ary-tree-postorder-traversal.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class Solution {
2828
for(auto& chlNode : root->children)
2929
{
3030
postorder(chlNode, ans);
31-
ans.push_back(chlNode->val);
3231
}
32+
ans.push_back(root->val);
3333
}
3434
}
3535

@@ -38,9 +38,7 @@ class Solution {
3838
vector<int> ans;
3939

4040
postorder(root, ans);
41-
if(root)
42-
ans.push_back(root->val);
43-
41+
4442
return ans;
4543

4644
}

0 commit comments

Comments
 (0)