As reported: Amazon SDE2 (Dublin, Sept 2025), round 2 — behavioural questions, then coding: connecting ropes at minimum cost, and removing duplicates from a sorted linked list while keeping it sorted.
Given the head of a sorted linked list, delete all duplicates so that each value appears only once. Return the list, still sorted.
This is LeetCode 83 — Remove Duplicates from Sorted List.
Example 1
head = [1,1,2]
Output: [1,2]
Example 2
head = [1,1,2,3,3]
Output: [1,2,3]
Constraints: 0 ≤ number of nodes ≤ 300; −100 ≤ Node.val ≤ 100; the list is sorted in ascending order.
Code runner format: one line: the list's values as a JSON array. Implement deleteDuplicates(head); the harness prints the returned list as a JSON array.