[Python] Accepted code: sometimes 51 ms & sometimes 63 mm


  • 0
    H

    Sometimes gives 51 ms and some other times 63 ms.
    I don't know why....

    class Solution(object):
        def deleteDuplicates(self, head):
            """
            :type head: ListNode
            :rtype: ListNode
            """
            trav, curr = head, head
    
            while curr:
                if trav and curr.val == trav.val:
                    trav = trav.next
                else:
                    curr.next = trav
                    curr = trav
            return head

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.