Remove Duplicates from Sorted List

Try to solve the Remove Duplicates from Sorted List problem.

Statement

Given the head of a sorted linked list, remove all duplicates such that each element appears only once, and return the list in sorted order.

Constraints:

  • 0≤0 \leq n ≤300\leq 300, where n is the number of nodes in the list.

  • −100≤-100 \leq Node.data ≤100\leq 100

  • The list is guaranteed to be sorted in ascending order.

Examples

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.