dsa · easy

Design Linked List

GreyOrangeLinked ListDesignFoundation

Implement a singly linked list with 0-based indices.

Methods

Fill in the MyLinkedList class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.

**Example**

`` MyLinkedList() → null addAtHead(1) → null addAtTail(3) → null addAtIndex(1, 2) → null get(1) → 2 deleteAtIndex(1) → null get(1) → 3 ``

Constraints

Calls <= 1000

Examples

Example 1

Input:
["MyLinkedList","addAtHead","addAtTail","addAtIndex","get","deleteAtIndex","get"]
[[],[1],[3],[1,2],[1],[1],[1]]

Expected:
[null,null,null,null,2,null,3]

Open in the Dojo editor