剑指Offer 18

删除重复的节点:

 1 class Solution:
 2     def deleteDuplication(self, pHead):
 3         if pHead == None or pHead.next == None:
 4             return pHead
 5         n = pHead.next
 6         if pHead.val == n.val:
 7             while n and pHead.val == n.val:
 8                 n = n.next
 9             return self.deleteDuplication(n)
10         else:
11             pHead.next = self.deleteDuplication(pHead.next)
12             return pHead
13         # write code here

 

上一篇:剑指offer 反转链表


下一篇:CUDA开发时用到的各种Linux命令