You are viewing a single comment's thread. Return to all comments →
My Java8 working solution, as simple as it can get:
public static Node removeDuplicates(Node head) { Node headCopy = head; while (headCopy != null){ if(headCopy.next!= null && headCopy.data == headCopy.next.data){ headCopy.next = headCopy.next.next; } else { headCopy = headCopy.next; } } return head; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 24: More Linked Lists
You are viewing a single comment's thread. Return to all comments →
My Java8 working solution, as simple as it can get: