Course · Section 11: Working With Arrays · Lecture 149: Simple Array Methods
Design a singly linked list (you may back it with any structure). Implement `MyLinkedList`: - `get(index)` returns the value at index, or `-1` if invalid. - `addAtHead(val)` / `addAtTail(val)`. - `addAtIndex(index, val)` inserts before index (append if index equals length; ignore if greater). - `deleteAtIndex(index)` removes the node at index if valid.
+ 1 hidden test run on Submit.
An index-validated sequence implements the linked-list API. The boundary rules on addAtIndex/deleteAtIndex are the tricky part.
Run your code to see results.