diff --git a/removeDuplicates.java b/removeDuplicates.java new file mode 100644 index 0000000..5896ff9 --- /dev/null +++ b/removeDuplicates.java @@ -0,0 +1,24 @@ +public static SinglyLinkedListNode removeDuplicates(SinglyLinkedListNode llist) { + // Write your code here + + if(llist == null){ + return llist; + } + + SinglyLinkedListNode new_head = llist; + + while(llist.next != null){ + + if(llist.data == llist.next.data){ + + llist.next = llist.next.next; + } + + else{ + llist = llist.next; + } + } + + return new_head; + + }