155: Remove duplicates from a sorted linked list

Given a sorted linked list, remove all duplicates such that each element appears only once

 

Example 1

Input:  1 -> 1 -> 2 -> 3 -> 3 -> 3 -> 4

Output: 1 -> 2 -> 3 -> 4

Example 2

Input:  1 -> 2 -> 3

Output: 1 -> 2 -> 3
Difficulty:Easy
Topic:Linked list
Problem #:155