4-Linked Lists/07. Linked List Problems_/JavaLinkedListDataStructures/JavaLinkedListDataStructures/LinkedList.java
public void removeDuplicates() {
        int count = countNodes();
        if (count == 0 || count == 1) {
            return;
        } else {
            Node<T> curr = head;
            do {
                if (curr.getNext().getData().compareTo(curr.getData()) == 0) {
                    // Skip over the duplicate node. It will be garbage collected
                    // by Java.
                    curr.setNext(curr.getNext().getNext());
                } else {
                    curr = curr.getNext();
                }
            } while (curr.getNext() != null);
        }
    }
/**
     * Remove duplicates in a sorted list.
     */
Remove duplicates in a sorted list.
Remove duplicates in a sorted list .
public void removeDuplicates() {
        int count = countNodes();
        if (count == 0 || count == 1) {
            return;
        } else {
            Node<T> curr = head;
            do {
                if (curr.getNext().getData().compareTo(curr.getData()) == 0) {
                    curr.setNext(curr.getNext().getNext());
                } else {
                    curr = curr.getNext();
                }
            } while (curr.getNext() != null);
        }
    }
public void removeDuplicates ( ) { int count = countNodes ( ) ; if ( count == 0 || count == 1 ) { return ; } else { Node < T > curr = head ; do { if ( curr . getNext ( ) . getData ( ) . compareTo ( curr . getData ( ) ) == 0 ) { curr . setNext ( curr . getNext ( ) . getNext ( ) ) ; } else { curr = curr . getNext ( ) ; } } while ( curr . getNext ( ) != null ) ; } }
Remove duplicates in a sorted list.
Remove duplicates in a sorted list .
// Skip over the duplicate node. It will be garbage collected // by Java.