133. Clone Graph
来源:互联网 发布:数据稀疏问题 编辑:程序博客网 时间:2024/06/05 11:30
/*图的复制,考虑到一点就是如果label相同时认为是同一节点,环的存在,因此是不可以再new,为了保证时间,用hashmap会比较快 */Map<Integer,UndirectedGraphNode> hashMap=new HashMap();public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) { if(node==null)return null; if(hashMap.containsKey(node.label)){ return hashMap.get(node.label); } UndirectedGraphNode clone=new UndirectedGraphNode(node.label); hashMap.put(node.label,clone); for(UndirectedGraphNode gn:node.neighbors){ clone.neighbors.add(cloneGraph(gn)); } return clone;}
阅读全文
0 0
- LeetCode 133. Clone Graph
- [Leetcode] 133. Clone Graph
- [leetcode] 133.Clone Graph
- 133. Clone Graph
- Leetcode 133. Clone Graph
- 133. Clone Graph LeetCode
- 133. Clone Graph
- LeetCode 133. Clone Graph
- leetcode 133. Clone Graph
- 133. Clone Graph
- 133. Clone Graph
- LeetCode *** 133. Clone Graph
- leetcode-133. Clone Graph
- LeetCode 133. Clone Graph
- 133. Clone Graph
- 133. Clone Graph
- 133. Clone Graph
- 133. Clone Graph
- Android 的toolbar设置返回事件
- CSS3 box-sizing 属性content-box或border-box
- 算法设计与应用基础系列11
- 【剑指offer-解题系列(60)】按之字形顺序打印二叉树
- 手机端访问第三方java服务器后判断是否进行OAuth2.0网页微信公众号授权认证
- 133. Clone Graph
- 我想学编程——向所有想学编程的人推荐《啊哈c语言》
- 微信开发之外网映射工具
- echarts 图表可配置展示功能 word 功能描述
- 什么是 值传递,地址传递和引用传递 有什么区别
- PHP如何调用Delphi开发的DataSnap/Restful接口服务
- Markdown--从入门到精通
- Cursor的moveToNext和moveToFirst
- 服务器搭建testlink (nginx php mysql环境) 心得分享