157: Remove duplicates from a sorted linked list 2

Given a sorted linked list, remove all duplicates

Note: Leave only distinct numbers from the given linked list

 

Example 1

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

Output: 2 -> 4

Example 2

Input:  1 -> 2 -> 3

Output: 1 -> 2 -> 3
Difficulty:Medium
Topic:Linked list
Problem #:157