美文网首页Leetcode
83. Remove Duplicates from Sorte

83. Remove Duplicates from Sorte

作者: oo上海 | 来源:发表于2016-07-29 10:19 被阅读9次

    83. Remove Duplicates from Sorted List

    题目:
    https://leetcode.com/problems/remove-duplicates-from-sorted-list/

    难度:

    Easy

    class Solution(object):
        def deleteDuplicates(self, head):
            """
            :type head: ListNode
            :rtype: ListNode
            """
            cur = head
            while cur:
                if cur.next:
                    if cur.val == cur.next.val:
                        cur.next = cur.next.next
                    else:
                        cur = cur.next
                # cur.next None
                else:
                    break
            return head
                    
    

    相关文章

      网友评论

        本文标题:83. Remove Duplicates from Sorte

        本文链接:https://www.haomeiwen.com/subject/bghzjttx.html