FastPrepDesign Linked List
Problems/Design Linked List

Design Linked List

The Walt Disney Company logoThe Walt Disney Company● EasyFULLTIMEOAONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names an onsite task to design a linked list, without the original API or edge conventions. This practice adds a bounded zero-based get/add-head/add-tail/add-at/delete interface, operation-array adapter and mutation acknowledgements. Its negative add-at and invalid-index behavior are explicit practice choices. The two implementations use actual linked nodes. About 70% of the reported task scope is represented, as an editorial estimate rather than recovered original detail.

Design a linked list that starts empty and processes operations in order. Use linked nodes for the stored sequence.

For this exercise, rows are [kind,index,value] and indices are zero-based:

  • 0: get the value at index, or -1 when index is invalid; value is ignored.
  • 1: add value at the head; index is ignored.
  • 2: add value at the tail; index is ignored.
  • 3: insert value before index. An index at most zero means the head; index equal to length appends; index greater than length does nothing.
  • 4: delete the node at index if 0 <= index < length; otherwise do nothing. Value is ignored.

Return one answer per row: get returns the observed value or -1; every other operation returns 0, including an ignored mutation. Duplicate and negative stored values are allowed. The interface and edge conventions are supplied for this practice.

Function

runLinkedList(operations: int[][]) → int[]

Examples

Example 1

operations = [[1,0,1],[2,0,3],[3,1,2],[0,1,0],[4,1,0],[0,1,0]]return = [0,0,0,2,0,3]

The list becomes [1], then [1,3], then [1,2,3]. Getting index 1 yields 2. Deleting it leaves [1,3], so the final get returns 3.

Example 2

operations = [[3,-2,8],[3,3,9],[0,-1,0],[4,-1,0],[0,0,0]]return = [0,0,-1,0,8]

Negative add-at inserts 8 at the head. Add-at index 3 is too large and is ignored. Negative get returns -1 and negative delete does nothing; the final get returns 8.

Constraints

  • 0 <= operations.length <= 1000
  • operations[i].length == 3
  • -1000000 <= operations[i][j] <= 1000000
  • Operation kinds are 0 through 4.
  • Implement the sequence with linked nodes; do not use a built-in list as the data structure that stores its values.

More The Walt Disney Company problems

  • Find All Paths for a Name in a File SystemPHONE SCREEN · Seen Nov 2026
  • Resizable Array-Backed Integer SetPHONE SCREEN · Seen Sep 2026
  • Shortest Path with Directional Move CostsPHONE SCREEN · Seen Sep 2026
All The Walt Disney Company interview questionsSee The Walt Disney Company hiring insights
Saved
class Solution {
    public int[] runLinkedList(int[][] operations) {
        // Write your code here
    }
}
Checking account…