[leetcode]Copy List with Random Pointer @ Python - 南郭子綦 - 博客园: "if head == None: return None
tmp = head
while tmp:
newNode = RandomListNode(tmp.label)
newNode.next = tmp.next
tmp.next = newNode
tmp = tmp.next.next
tmp = head
while tmp:
if tmp.random:
tmp.next.random = tmp.random.next
tmp = tmp.next.next
newhead = head.next
pold = head
pnew = newhead
while pnew.next:
pold.next = pnew.next
pold = pold.next
pnew.next = pold.next
pnew = pnew.next
pold.next = None
pnew.next = None
return newhead"
'via Blog this'
Blog Archive
-
▼
2014
(190)
-
▼
September
(29)
- [Leetcode] Longest Valid Parentheses @Python - Sum...
- 霸气侧漏的在读博士
- Programming Interview Questions
- temp
- InstallingANewHardDrive - Community Help Wiki
- Clustering With K-Means in Python | The Data Scien...
- LeetCode题解整理版(二) | Coding 4 Fun
- [leetcode]Simplify Path @ Python - 南郭子綦 - 博客园
- [leetcode]Implement strStr() @ Python - 南郭子綦 - 博客园
- [leetcode]Valid Palindrome @ Python - 南郭子綦 - 博客园
- [leetcode]Copy List with Random Pointer @ Python -...
- [leetcode]Swap Nodes in Pairs @ Python - 南郭子綦 - 博客园
- [leetcode]Remove Nth Node From End of List @ Pytho...
- [leetcode]Add Two Numbers @ Python - 南郭子綦 - 博客园
- [leetcode]Rotate List @ Python - 南郭子綦 - 博客园
- [leetcode]Plus One @ Python - 南郭子綦 - 博客园
- [leetcode]Valid Sudoku @ Python - 南郭子綦 - 博客园
- How to Read Linux Top Command Output and Uses - Te...
- [leetcode]Valid Sudoku @ Python - 南郭子綦 - 博客园
- Dropped iphone 5 in water. Help? | Apple Support C...
- [leetcode]Permutation Sequence @ Python - 南郭子綦 - 博客园
- C++11 improvements over C++03
- K-means算法及k-means++、SVD的优化 - 推酷
- Programming Interview Questions
- 统计学习笔记(2)——感知机模型 - Liam Q的专栏 - 博客频道 - CSDN.NET
- 科学网—[转载]常见面试之机器学习算法思想简单梳理 - 李建扣的博文
- soulmachine/machine-learning-cheat-sheet
- 美国一类优先移民EB1A
- c++ - Compiling C++11 with g++
-
▼
September
(29)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment