FastPrepRemove Duplicates from a Sorted Linked List
Problems/Remove Duplicates from a Sorted Linked List

Remove Duplicates from a Sorted Linked List

AMD logoAMD● EasyNEW GRADONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source asks to remove duplicates from a sorted linked list. Keeping one per run, mutation permission, bounds and callable interface are authored explicit completion; approximate source match90%.

Remove repeated values from the sorted linked list so exactly one node remains for each distinct value. Preserve nondecreasing order. Keep one representative from an entire equal-value run; do not delete all occurrences of a repeated value. You may modify the input links in place.

Function

deduplicateList(head: ListNode) → ListNode

Examples

Example 1

head = [1,1,2,3,3]return = [1,2,3]

The runs [1,1], [2] and [3,3] each contribute one node.

Example 2

head = []return = []

An empty list has no values to retain.

Constraints

  • 0 <= head.length <= 500.
  • -1000000 <= head[i] <= 1000000.
  • The list is acyclic and its values are nondecreasing.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public ListNode deduplicateList(ListNode head) {
    // Write your code here.
}
Checking account…