Code works in leetcode


#1

Commpublic class Solution {
public ListNode deleteDuplicates(ListNode A) {
if(A==null)
return null;

    ListNode slow = A;
    ListNode fast = A.next;
  
    
    while(fast!=null){
        if(slow.val==fast.val){
            fast = fast.next;
        }
        else{
            slow.next = fast;
            slow = fast;
        }
    }
    
    slow.next = null;
  
    return A;
    
}

}ent body goes here.