← Arista Interview Insights

Arista·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Did a coding round for a Software Engineer role at Arista. One question, linked list manipulation, nothing flashy but it required some care to get right in-place.

Questions Asked (1)

Q1

Given the head of a singly linked list and a target integer, remove all nodes with that value and return the updated head. Do it in-place, no auxiliary list.

Algorithms & Data Structures
Author's notes

Seems straightforward until you realize the head itself might need to be removed.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a dummy node pointing to the head to simplify edge cases, then traverse the list with a current pointer, skipping nodes whose value equals the target. Return dummy.next as the new head.

Pro tip: Explicitly discuss edge cases like removing the head node or all nodes, and mention that the dummy node technique avoids separate handling for the head. Also, note that the solution runs in O(n) time and O(1) space.

1. Clarify and Confirm

Ask clarifying questions: Is the list singly linked? Can the head be null? Should we free memory? Confirm the target value and that in-place modification is required.

2. Plan with Dummy Node

Explain that you'll create a dummy node pointing to the head to handle cases where the head itself needs removal. This simplifies pointer manipulation.

3. Traverse and Remove

Iterate through the list with a current pointer starting at the dummy. While current.next exists, if current.next.val equals target, skip it by setting current.next = current.next.next; otherwise, advance current.

4. Return New Head

After traversal, return dummy.next as the new head of the modified list. Discuss time and space complexity: O(n) time, O(1) space.

Key Points to Mention

  • Dummy node technique to handle head removal uniformly
  • In-place modification without auxiliary data structures
  • Time complexity O(n) and space complexity O(1)
  • Edge cases: empty list, target at head, all nodes removed
  • Pointer manipulation: skipping nodes by adjusting next pointers
  • Memory management considerations (if applicable in C/C++)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.