【LeetCode with Python】 Remove Duplicates from Sorted List
2008-12-07 13:17
666 查看
博客域名:http://www.xnerv.wang
原题页面:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/
题目类型:链表
难度评价:★
本文地址:/article/1377549.html
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.
For example,
Given
Given
有序链表的去重,注意及时检查一些引用是否为None。
原题页面:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/
题目类型:链表
难度评价:★
本文地址:/article/1377549.html
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.
For example,
Given
1->1->2, return
1->2.
Given
1->1->2->3->3, return
1->2->3.
有序链表的去重,注意及时检查一些引用是否为None。
class Solution: # @param head, a ListNode # @return a ListNode def deleteDuplicates(self, head): if None == head or None == head.next: return head cur = head while None != cur: if None != cur.next and cur.val == cur.next.val: cur.next = cur.next.next continue else: cur = cur.next return head
相关文章推荐
- 【LeetCode with Python】 Remove Duplicates from Sorted List II
- 链表-python-leetcode 83 Remove Duplicates from Sorted List
- [leetcode]Remove Duplicates from Sorted List @ Python
- 【Leetcode】【python】Remove Duplicates from Sorted List/Remove Duplicates from Sorted List II
- leetcode 【 Remove Duplicates from Sorted List 】 python 实现
- LeetCode 83 — Remove Duplicates from Sorted List(C++ Java Python)
- Leetcode-Remove Duplicates from Sorted List-Python
- [LeetCode]Remove Duplicates from Sorted List@python
- 【LeetCode with Python】 Remove Duplicates from Sorted Array
- 【LeetCode 83】Remove Duplicates from Sorted List (Python)
- Python学习——leetcode(Remove Duplicates from Sorted List)
- [LeetCode]题解(python):082-Remove Duplicates from Sorted List II
- 83. Remove Duplicates from Sorted List Leetcode Python
- 【LeetCode with Python】 Remove Duplicates from Sorted Array II
- [leetcode]Remove Duplicates from Sorted List II @ Python
- [LeetCode]题解(python):083-Remove Duplicates from Sorted List
- leetcode 【 Remove Duplicates from Sorted List II 】 python 实现
- 【LEETCODE】82- Remove Duplicates from Sorted List II [Python]
- [LeetCode]Remove Duplicates from Sorted List II@python
- 【LeetCode with Python】Remove Duplicates from Sorted Array II