Clean Python Code Beats 86%

  • 0
    class Solution(object):
    def removeElements(self, head, val):
        if head == None:
            return head
        while(head != None and head.val == val):
            head =
        if head == None:
            return head
        prev, current = head,
        while (current != None):
            while (current.val == val):
                if == None:
                    return head
                current =
            prev,current = current,
        return head

Log in to reply

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