[leetcode]138. Copy List with Random Pointer
来源:互联网 发布:it求职 编辑:程序博客网 时间:2024/06/06 22:46
题目链接:https://leetcode.com/problems/copy-list-with-random-pointer/tabs/description
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
class Solution {private: unordered_map<RandomListNode*, RandomListNode*> hmap;public: RandomListNode *copyRandomList(RandomListNode *head) { if (!head) return NULL; if (hmap.find(head) != hmap.end()) return hmap.find(head)->second; RandomListNode* node = new RandomListNode(head->label); hmap[head] = node; node->next = copyRandomList(head->next); node->random = copyRandomList(head->random); return node; }};
阅读全文
0 0
- LeetCode 138. Copy List with Random Pointer
- [Leetcode] 138. Copy List with Random Pointer
- LeetCode 138. Copy List with Random Pointer
- [leetcode] 138. Copy List with Random Pointer
- LeetCode 138. Copy List with Random Pointer
- LeetCode 138. Copy List with Random Pointer
- leetcode.138. Copy List with Random Pointer
- LeetCode-138.Copy List with Random Pointer
- Leetcode 138. Copy List with Random Pointer
- [Leetcode]138. Copy List with Random Pointer
- LeetCode 138. Copy List with Random Pointer
- [LeetCode] 138. Copy List with Random Pointer
- [LeetCode]138. Copy List with Random Pointer
- LeetCode 138. Copy List with Random Pointer
- Leetcode-138. Copy List with Random Pointer
- Leetcode 138. Copy List with Random Pointer
- leetcode 138. Copy List with Random Pointer
- Leetcode 138. Copy List with Random Pointer
- oracle 去重并按时间排序取第一条
- openlayer学习总结
- JavaScript—className 属性
- 制作tensorflow标准数据集即制作.tfrecords格式文件
- Java基础之三目运算符,if,switch
- [leetcode]138. Copy List with Random Pointer
- nginx 配置信息
- Fri Jul 28 16:19:08 CST 2017 WARN: Establishing SSL connection without server's identity verificati
- vs重装路径无法修改问题的解决
- Android之aidl进程通信
- zabbix-proxy安装配置
- JavaScript笔记(事件属性)
- 简单实例理解装饰者设计模式
- 本地搭建 wordpress 实例