Easy Clean Java Solution


  • 0
    public class Solution {
        public ListNode deleteDuplicates(ListNode head) {
            ListNode cur = head;
            
            while(cur != null && cur.next != null) {
                if (cur.val == cur.next.val) {
                    cur.next = cur.next.next;
                } else
                    cur = cur.next;
            }
            return head;
        }
    }
    

Log in to reply
 

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