Skip to content

Commit

Permalink
1490
Browse files Browse the repository at this point in the history
  • Loading branch information
lzl124631x committed Mar 1, 2022
1 parent 52bcc9d commit d7ba83a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions leetcode/1490. Clone N-ary Tree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class Solution {
public:
Node* cloneTree(Node* root) {
if (!root) return nullptr;
vector<Node*> children;
for (auto ch : root->children) children.push_back(cloneTree(ch));
return new Node(root->val, children);
auto cpy = new Node(root->val);
for (auto &c : root->children) cpy->children.push_back(cloneTree(c));
return cpy;
}
};
```

0 comments on commit d7ba83a

Please sign in to comment.