Add linked-list module: singly and doubly lists with measured costs, reverse, middle, Floyd cycle detection, merge and 5 more interview problems, the 2015 menu programs and a doubly-list bug they exposed (15 tests, 15 transcripts)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6r9iSyHu5qSJMzH2n
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
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
|
||||
Reference in New Issue
Block a user