← Back to section

Final exam — Linked List

Three unseen problems (not covered in the lessons) to test whether you leave this section able to solve any problem of the topic: one easy, one medium and one hard. Some test cases are hidden — like the real LeetCode. Solve in Python or JavaScript.

Easy

Remove Duplicates from Sorted List

Given the head of a sorted linked list, remove the nodes with duplicate values, leaving each value only once. Return the list.

Example: 1 → 1 → 2 → 3 → 3 → 1 → 2 → 3.

Carregando editor…
Medium

Odd Even Linked List

Regroup the list so that all nodes in odd positions (1st, 3rd, 5th...) come first, followed by those in even positions — keeping the relative order of each group. Do it in O(1) space. Return the list.

Example: 1 → 2 → 3 → 4 → 5 → 1 → 3 → 5 → 2 → 4.

Carregando editor…
Hard

Reverse Nodes in k-Group

Reverse the nodes of the list in groups of k. If the last group has fewer than k nodes, leave it as is. Return the list.

Example: 1 → 2 → 3 → 4 → 5, k = 2 → 2 → 1 → 4 → 3 → 5. With k = 3 → 3 → 2 → 1 → 4 → 5.

Carregando editor…