As reported: Siemens EDA, SDE-1 / 6-month internship + PPO, single ~2h20m technical interview (2026): write a linked-list node, then implement a doubly linked list; followed by questions on inheritance, constructor behaviour and
new.
Implement a doubly linked list class MyLinkedList. Each node holds a value and pointers to both its previous and its next node. Indices are 0-based.
MyLinkedList()— an empty list.get(index)— the value at positionindex, or-1if the index is invalid.addAtHead(val)— insertvalbefore the first element.addAtTail(val)— appendvalas the last element.addAtIndex(index, val)— insertvalbefore the element atindex. Ifindexequals the length, append it; ifindexis greater than the length, do nothing.deleteAtIndex(index)— delete the element atindexif the index is valid.
This is LeetCode 707 — Design Linked List, in its doubly linked form.
Example
["MyLinkedList","addAtHead","addAtTail","addAtIndex","get","deleteAtIndex","get"]
[[],[1],[3],[1,2],[1],[1],[1]]
-> [null,null,null,null,2,null,3]
The list goes 1 → 1,3 → 1,2,3; get(1) is 2; deleting index 1 leaves 1,3; get(1) is 3.
Constraints: 0 ≤ index, val ≤ 1000; at most 2000 calls in total.
Code runner format: two lines, LeetCode's design format — the list of operation names and the list of argument lists. Implement MyLinkedList (in Go the methods are Get, AddAtHead, …); the harness prints the list of results (null for the constructor and void methods).