← Salesforce Interview Insights

Salesforce·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Salesforce software engineer coding round, pretty much one big linked list problem with multiple variants. They wanted full solutions, complexity analysis, and edge case tests all in one go, which felt like a lot to juggle in real time.

Questions Asked (1)

Q1

Given a singly linked list, remove duplicate values in-place. For a sorted list, delete repeated nodes so each value appears once using O(1) extra space. For an unsorted list, preserve the first occurrence of each value and provide two solutions: one using a hash set and one using the runner technique without extra memory. Define your ListNode type, explain correctness, analyze time and space complexity for each approach, and include tests for edge cases like empty list, single node, all duplicates, and no duplicates.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This was way more layered than I expected for what sounded like a warmup question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the ListNode type and clarifying the sorted vs unsorted cases. For sorted lists, use a single pointer to skip duplicates in O(n) time and O(1) space. For unsorted lists, present two solutions: one using a hash set for O(n) time and O(n) space, and one using the runner technique for O(n^2) time and O(1) space, explaining trade-offs.

Pro tip: Emphasize that the runner technique, while O(n^2), is valuable when memory is constrained, and always discuss edge cases and test them to demonstrate thoroughness.

1. Define ListNode and clarify cases

Define the ListNode class with val and next fields. Clearly distinguish between sorted and unsorted list scenarios and the constraints for each.

2. Sorted list solution

Traverse the list with a current pointer. If current.next has the same value, skip it by adjusting pointers; otherwise, move to the next node. This removes duplicates in-place with O(1) extra space.

3. Unsorted list with hash set

Traverse the list, keeping a hash set of seen values. If a value is already in the set, remove the node by adjusting pointers; otherwise, add it to the set and move forward. This preserves first occurrences.

4. Unsorted list with runner technique

For each node, use a runner pointer to scan ahead and remove any subsequent nodes with the same value. This uses O(1) extra space but O(n^2) time.

5. Analyze complexity and test edge cases

For each approach, state time and space complexity. Write tests covering empty list, single node, all duplicates, and no duplicates to verify correctness.

Key Points to Mention

  • Definition of ListNode with val and next fields.
  • Correctness argument: for sorted list, invariant that all nodes before current have unique values; for unsorted, hash set ensures first occurrence is kept, runner technique compares each node with all subsequent nodes.
  • Time and space complexity: sorted O(n) time O(1) space; hash set O(n) time O(n) space; runner O(n^2) time O(1) space.
  • Trade-offs: hash set is faster but uses extra memory; runner is slower but memory-efficient.
  • Edge cases: empty list, single node, all duplicates, no duplicates.
  • In-place modification: adjusting next pointers without creating new nodes.

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