Leetcode

83. Remove Duplicates from Sorte

2016-07-29  本文已影响9人  oo上海

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
                
上一篇下一篇

猜你喜欢

热点阅读