Why this python code is not working?


#1

Definition for singly-linked list.

class ListNode:

def init(self, x):

self.val = x

self.next = None

class Solution:
# @param A : head node of linked list
# @return the head node in the linked list
def deleteDuplicates(self, A):
current = A
nxt = current.next

    while current:
        if nxt.val == current.val:
            nxt = nxt.next
        
        else:
            current.next = nxt
            current = nxt
            nxt = nxt.next
            current = current.next
    
    return A

#2

ig it’s because you’re not changing the currents’s next pointer.

A --> A.next – >
^ current