Share my 320ms Java solution


  • 3
    X
    public class Solution {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode curP = head;
        while(curP!=null){
            while(curP.next!=null&&curP.val ==curP.next.val){
                curP.next = curP.next.next;
            }
            curP=curP.next;
        }
        return head;
    }
    

    }


Log in to reply
 

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