Build challenges · 4 steps · javascript · python
Singly Linked List
Construct a Singly Linked List with ListNode pointers, append, prepend, index-based insertion, deletion, and in-place reversal.
Unlike arrays that allocate contiguous memory blocks, a Linked List stores elements across independent nodes joined by memory pointers.
In this build, you will construct a Singly Linked List from scratch:
- Implement
ListNodepointer chaining with $O(1)$appendandprepend. - Implement index-based node access (
getAt) and insertion (insertAt). - Safely unlink and delete nodes while maintaining boundary references (
deleteAt). - Reverse the entire chain in-place with $O(1)$ auxiliary space (
reverse).
The workspace
These files carry across every step. What you write in one step is what you start the next with.
- linked_list.js
- harness.jsread-only
Steps · 0 of 4 done
Start anywhere. Open step 3 first and you are handed the reference build of steps 1 and 2, so every step stands on its own. Nothing here is locked behind anything else.
This build applies Linked Lists. Read the lesson first if it is unfamiliar — a recommendation, not a prerequisite.