[LeetCode] Copy List with Random Pointer
来源:互联网 发布:实体店铺设计软件 编辑:程序博客网 时间:2024/05/22 17:40
RandomListNode *copyRandomList(RandomListNode *head) {if(head == NULL) {return NULL;}RandomListNode* curNode = head; while(curNode != NULL) {RandomListNode* curCopyNode = new RandomListNode(curNode->label);RandomListNode* nextNode = curNode->next;curNode->next = curCopyNode;curCopyNode->next = nextNode;curNode = nextNode;}curNode = head;while(curNode != NULL) {if(curNode->random != NULL) {curNode->next->random = curNode->random->next;}curNode = curNode->next->next;}RandomListNode* copyListHead = head->next;curNode = head;while(curNode != NULL) {RandomListNode* curCopyNode = curNode->next;RandomListNode* nextNode = curCopyNode->next;RandomListNode* nextCopyNode = NULL;if(nextNode != NULL) {nextCopyNode = nextNode->next;}curNode->next = nextNode;curCopyNode->next = nextCopyNode;curNode = nextNode;}return copyListHead;}
0 0
- [leetcode][list] Copy List with Random Pointer
- Leetcode: Copy List with Random Pointer
- LeetCode: Copy List with Random Pointer
- [LeetCode] Copy List with Random Pointer
- [leetcode]Copy List with Random Pointer
- LeetCode:Copy List with Random Pointer
- leetcode Copy List with Random Pointer
- LeetCode:Copy List with Random Pointer
- LeetCode题解:Copy List with Random Pointer
- [LeetCode]Copy List with Random Pointer
- leetcode Copy List with Random Pointer
- leetcode-Copy List with Random Pointer
- Leetcode: Copy List with Random Pointer
- LeetCode | Copy List with Random Pointer
- [LeetCode] Copy List with Random Pointer
- LeetCode OJ:Copy List with Random Pointer
- LeetCode(138)Copy List with Random Pointer
- [LeetCode] - Copy List with Random Pointer
- SyntaxHighlighter2.1.364详细配置使用说明
- U3D:注意事项
- Objective C--中介者模式
- log4j日志文件乱码问题的解决方法
- LINQ实现多次调用GroupBy进行分组统计
- [LeetCode] Copy List with Random Pointer
- Wince 6.0 device关联调查
- KVO Key Value Observing 基于键值的观察者
- 人生的正道,也是人生的希望
- mysql访问量过大时需要调整的参数
- 真正的成功,存于玻璃瓶外
- 重写系统viewpager 实现每次切换每个页面都重新加载
- 帧动画
- conteros yum 安装mysql