problem
1 | Clone a graph. Input is a Node pointer. Return the Node pointer of the cloned graph. |
code
1 | typedef unordered_map<Node *, Node *> Map; |
anlysis
using the Breadth-first traversal
and use a map to save the neighbors not to be duplicated.
1 | Clone a graph. Input is a Node pointer. Return the Node pointer of the cloned graph. |
1 | typedef unordered_map<Node *, Node *> Map; |
using the Breadth-first traversal
and use a map to save the neighbors not to be duplicated.
WeChat Pay
Alipay