LeetCode — Remove Duplicates from Sorted list

Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.

Example 1:

Input: head = [1,1,2]
Output: [1,2]

Example 2:

Input: head = [1,1,2,3,3]
Output: [1,2,3]


  • The number of nodes in the list is in the range [0, 300].
  • -100 <= Node.val <= 100
  • The list is guaranteed to be sorted in ascending order.





Dell Technologies — VxRail Software Engineer 👨‍💻

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Is it a group though?

CSS Cascade

Introduction to JavaScript

Smart CLI service to create store, actions, reducer and saga with dynamic options



Cloning eBay’s frontend with the custom-made server

Implementation of Binary Search

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Steven Lu

Steven Lu

Dell Technologies — VxRail Software Engineer 👨‍💻

More from Medium

DSA — Flowcharts & Algorithms

Remove Zero Sum Consecutive Nodes from Linked List

Leetcode 48 : Rotate Image

Linked List — Circular