Skip to content
DSA linked lists 5 min read

Linked List Exercises: Practice Problems (with Solutions)

Time to practice. Solve each problem yourself first — sketch the nodes on paper, trace your pointer moves on a tiny example, and reason about time and space before you write a line. Only then open the answer sheet. Every View answer link jumps to a full, multi-language solution on the linked list solutions page.

How to practice: Drawing the boxes-and-arrows by hand is not optional for linked lists — it is how you avoid losing the tail. If you’re stuck, re-read the operations and fast & slow pointers pages before peeking.

Warm-ups

Q1. Reverse a singly linked list. Given the head of a list, reverse it and return the new head. Target O(n) time and O(1) space.

View answer →

Q2. Find the middle node. Return the middle node of a singly linked list in a single pass. For an even-length list, return the second of the two middle nodes.

View answer →

Core problems

Q3. Detect a cycle. Determine whether a linked list contains a cycle. Use O(1) extra space.

View answer →

Q4. Merge two sorted lists. Given the heads of two sorted linked lists, splice them into one sorted list and return its head. Reuse the existing nodes (no new allocation for values).

View answer →

Q5. Remove the Nth node from the end. Given the head and an integer n, delete the nth node counting from the end and return the head. Do it in one pass.

View answer →

Challenge

Q6. Palindrome linked list. Return whether the list reads the same forward and backward. Aim for O(n) time and O(1) extra space.

View answer →

Q7. Detect the cycle’s start node. If the list has a cycle, return the node where it begins; otherwise return null. Use O(1) extra space.

View answer →


Done? Review every solution on the linked list answer sheet — even the ones you solved, since there’s often a cleaner approach. Then continue to stacks.

Last updated June 25, 2026
Was this helpful?