Python Compile Error -- please ignore the class indent.


  • 0
    W
    import collections  class Solution:
    # @param head, a ListNode
    # @return a ListNode
    def deleteDuplicates(self, head):
        node = head
        lst = []
        while node is not None:
            lst.append(node)
            node = node.next
        return list(collections.OrderedDict.fromkeys(lst))

  • 0
    S

    Do not import anything by yourself, like import collections.

    You can assume all necessary libraries are already imported, and if anything you really want and cannot get rid of it, please email admin@leetcode.com and describe the situation, we might consider add it.

    BTW, I believe such solution of this problem like yours is too simple to accept by interviewers.


Log in to reply
 

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