clueless coding // TODO: be smarter

LeetCode Remove Duplicates from Sorted List: Java Solution



TL;DR Code Solution


public ListNode deleteDuplicates(ListNode head) {

    ListNode runner = head;

    while (runner != null && runner.next != null) {
        if (runner.val == runner.next.val) {
            runner.next = runner.next.next;
        }
        else {
            runner = runner.next;
        }
    }


    return head;


}