FastPrepLinked List Add and Remove Operations
Problems/Linked List Add and Remove Operations

Linked List Add and Remove Operations

Adobe logoAdobe● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: In the first of three same-day rounds, after a word-transformation question, the candidate got a question on adding and removing nodes in a linked list. That one line is all the report gives.

It does not say which operations, how positions work, or what to return. Here there are four operations (add at the head, at the tail or at a position, and remove at a position), positions count from 0, every index is valid, there are at most 1000 operations with values from -1000 to 1000, and you return the final list. The examples are new.

The judged task matches the report at about 65%.

Implement a singly linked list of integers. It starts empty, and positions are counted from 0 at the head. It supports four operations:

  • "addFirst v": add a node with value v at the head.
  • "addLast v": add a node with value v at the tail.
  • "addAt i v": add a node with value v so that it ends up at position i. The node that was at position i, if any, and everything after it move back by one. If i equals the current size, the node goes at the tail.
  • "removeAt i": remove the node at position i.

You get the operations in order as the string array operations. Run them all and return the values of the final list from head to tail (an empty array if the list is empty).

Function

applyListOperations(operations: String[]) → int[]

Examples

Example 1

operations = ["addLast 4","addFirst 9","addAt 1 7","addLast 2","removeAt 0"]return = [7,4,2]

The list changes like this: [4], then [9, 4], then [9, 7, 4] (7 goes in at index 1), then [9, 7, 4, 2], and removing index 0 leaves [7, 4, 2].

Example 2

operations = ["addAt 0 5","addAt 1 -3","addAt 1 0"]return = [5,0,-3]

addAt 0 5 on an empty list gives [5]. addAt 1 -3 adds at the end, giving [5, -3]. addAt 1 0 puts 0 before the old index-1 node: [5, 0, -3].

Example 3

operations = ["addFirst 1","removeAt 0"]return = []

The only node is removed, so the list ends empty.

Constraints

  • 1 <= operations.length <= 1000
  • Each operation has one of the four forms above, with single spaces and integers written in plain decimal.
  • Every value v satisfies -1000 <= v <= 1000.
  • Every index is valid when its operation runs: 0 <= i <= size for addAt and 0 <= i < size for removeAt.

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public int[] applyListOperations(String[] operations) {
    // Write your code here.
}
Checking account…