← Arista Networks Interview Insights

Arista Networks·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Interviewed for a software engineer role at Arista Networks and got a linked list problem that looked easy on the surface but had enough edge cases to trip you up if you weren't careful about how you handled the head pointer.

Questions Asked (1)

Q1

Given the head of a singly linked list and an integer target, remove all nodes with that value and return the new head. The target can appear at the head, middle, or tail any number of times.

Algorithms & Data Structures
Author's notes

My first instinct was to just walk the list and splice out matching nodes, which works fine for the middle and tail.

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. Finally, return dummy.next as the new head.

Pro tip: Always consider edge cases like an empty list, all nodes matching the target, or the target at the head; using a dummy node elegantly handles these without special-case code.

1. Clarify and confirm

Restate the problem to ensure understanding: remove all nodes with the given value, return the new head. Ask if the list can be empty or if the target may not exist.

2. Choose the dummy node technique

Explain that a dummy node simplifies removal at the head. Create a dummy node with next pointing to the original head.

3. Traverse and remove

Use a pointer (prev) starting at dummy. While prev.next is not null, if prev.next.val equals target, skip the node by setting prev.next = prev.next.next; otherwise, move prev forward.

4. Return the new head

After traversal, return dummy.next, which points to the new head of the modified list.

5. Analyze complexity and test

State time complexity O(n) and space O(1). Walk through edge cases: empty list, all nodes removed, target at head/tail, no target present.

Key Points to Mention

  • Use of a dummy node to handle head removal uniformly
  • Single-pass traversal with O(n) time and O(1) space
  • Pointer manipulation: prev.next = prev.next.next to skip nodes
  • Edge cases: empty list, all nodes match, target at head/tail, no match
  • Returning dummy.next as the new head
  • Avoiding common pitfalls like losing reference to the head or not updating pointers correctly

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