(LinkedListNode n)
| 8 | |
| 9 | public class Question { |
| 10 | public static void deleteDupsA(LinkedListNode n) { |
| 11 | HashSet<Integer> set = new HashSet<Integer>(); |
| 12 | LinkedListNode previous = null; |
| 13 | while (n != null) { |
| 14 | if (set.contains(n.data)) { |
| 15 | previous.next = n.next; |
| 16 | } else { |
| 17 | set.add(n.data); |
| 18 | previous = n; |
| 19 | } |
| 20 | n = n.next; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | public static void deleteDupsC(LinkedListNode head) { |
| 25 | if (head == null) return; |