133. Clone Graph
生活随笔
收集整理的這篇文章主要介紹了
133. Clone Graph
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
歡迎fork and star:Nowcoder-Repository-github
133. Clone Graph
題目
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and each neighbor of the node.As an example, consider the serialized graph {0,1,2#1,2#2,2}.The graph has a total of three nodes, and therefore contains three parts as separated by #.First node is labeled as 0. Connect node 0 to both nodes 1 and 2.Second node is labeled as 1. Connect node 1 to node 2.Third node is labeled as 2. Connect node 2 to node 2 (itself), thus forming a self-cycle.Visually, the graph looks like the following:1/ \/ \0 --- 2/ \\_/解析
- 考察圖的基本遍歷方法,DFS/BFS
- 注意細(xì)節(jié)bug
- 運(yùn)用unordered_map<UndirectedGraphNode*, UndirectedGraphNode*> hash進(jìn)行圖的映射關(guān)系存儲(chǔ)
題目來(lái)源
- 133. Clone Graph
總結(jié)
以上是生活随笔為你收集整理的133. Clone Graph的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手把手0基础项目实战(一)——教你搭建一
- 下一篇: android布局中使用include及