【LeetCode with Python】 Remove Duplicates from Sorted List II
来源:互联网 发布:mac怎么找到安装目录 编辑:程序博客网 时间:2024/06/06 11:03
博客域名:http://www.xnerv.wang
原题页面:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
题目类型:
难度评价:★
本文地址:http://blog.csdn.net/nerv3x3/article/details/38929151
原题页面:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
题目类型:
难度评价:★
本文地址:http://blog.csdn.net/nerv3x3/article/details/38929151
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5
, return 1->2->5
.
Given 1->1->1->2->3
, return 2->3
.
class Solution: # @param head, a ListNode # @return a ListNode def deleteDuplicates(self, head): if None == head or None == head.next: return head new_head = ListNode(-1) new_head.next = head parent = new_head cur = head while None != cur and None != cur.next: ### check cur.next None if cur.val == cur.next.val: val = cur.val while None != cur and val == cur.val: ### check cur None cur = cur.next parent.next = cur else: cur = cur.next parent = parent.next return new_head.next
0 0
- 【LeetCode with Python】 Remove Duplicates from Sorted List II
- 【Leetcode】【python】Remove Duplicates from Sorted List/Remove Duplicates from Sorted List II
- 【LeetCode with Python】 Remove Duplicates from Sorted Array II
- 82. Remove Duplicates from Sorted List II Leetcode Python
- 【LEETCODE】82- Remove Duplicates from Sorted List II [Python]
- 【LeetCode with Python】 Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List II
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List II
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List II
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode]Remove Duplicates from Sorted List II
- [leetcode]Remove Duplicates from Sorted List II
- LeetCode-Remove Duplicates from Sorted List II
- [leetcode] Remove Duplicates from Sorted List II
- LeetCode - Remove Duplicates from Sorted List II
- Cocos2d-x 3.0开发(五)关联程序逻辑与cocoStudio导出文件
- NYOJ-九的余数
- -
- 深入分析Linux内核源码——6.3 内存的分配和回收
- .NET程序的代码混淆、加壳与脱壳
- 【LeetCode with Python】 Remove Duplicates from Sorted List II
- FZU 2064(暴力求解)
- Cocos2d-x 3.0 开发(四)使用CocoStudio创建UI并载入到程序中
- Codeforces Round #245 (Div. 1)B 递推DP
- 继承于CCObject而非CCLayer的界面的显示
- 【LeetCode with Python】 Remove Duplicates from Sorted Array II
- WPF/Silverlight深度解决方案:(二)Silverlight源码之自我保护(加密)
- android自带zip轻松实现压缩解压
- 7.27派生类的析构函数