Files
java-interview-lab/linked-list/output/01-nodes-and-links.txt
T

14 lines
509 B
Plaintext

A linked list is nodes that point at each other
===============================================
a.val = 10 a.next.val = 20 a.next.next.val = 30 a.next.next.next = null
whole list from a: 10 -> 20 -> 30 -> null
length: 3
new node 15 points at 20: 15 -> 20 -> 30 -> null
a still reaches the old chain: 10 -> 20 -> 30 -> null
then a.next = the new node: 10 -> 15 -> 20 -> 30 -> null
one new object and one changed link; nothing else moved.
the empty list is null: ListNode.of() == null -> true