Почему в моем учебнике говорится, что сложность пространства для этого алгоритма равна O (1)? Я чувствую, что это O (n) для размера связанного списка.
public static void deleteDups(LinkedListNode head) {
LinkedListNode current = head;
while (current != null) {
/* Remove all future nodes that have the same value */
LinkedListNode runner = current;
while (runner.next != null) {
if (runner.next.data == current.data) {
runner.next = runner.next.next;
} else {
runner = runner.next;
}
}
current = current.next;
}
}