Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Remove Duplicates from Sorted List

Easy
linked-list

Given the head of a sorted linked list, delete duplicates so each value appears once, and return the (still sorted) list.

Input: one line of space-separated integers (sorted). Output: the deduplicated list's values.

Example 1
Input:
1 1 2
Output:
1 2
Example 2
Input:
1 1 2 3 3
Output:
1 2 3

Constraints

  • 0 ≤ list length ≤ 300
  • Sorted non-decreasing.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.