Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a function to remove duplicates from a sorted linked list.

Hard

Problem Statement

Implement a function to remove duplicates from a sorted linked list.

Sample Input

A sorted linked list: 1 -> 1 -> 2 -> 3 -> 3.

Sample Output

1 -> 2 -> 3 -> null

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
class ListNode(val value: Int) { var next: ListNode? = null } fun removeDuplicates(head: ListNode?): ListNode? { // Add your code here to remove duplicates } fun main() { // Build linked list and test the function }
Log in or sign up to run or submit your code.Log inSign up
Input
A sorted linked list: 1 -> 1 -> 2 -> 3 -> 3.
Expected Output
1 -> 2 -> 3 -> null