You are viewing a single comment's thread. Return to all comments →
Java
public static Node removeDuplicates(Node head) { if(head==null||head.next==null){ return head; } List<Integer> list = new ArrayList<>(); Node current = head; while(current.next!=null){ list.add(current.data); if(list.contains(current.next.data)){ // skip the next node current.next = current.next.next; }else { current = current.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 →
Java