Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6r9iSyHu5qSJMzH2n
14 lines
509 B
Plaintext
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
|