Linked lists interview questions
Chains of links: turning them around, fast and slow pointers, the placeholder head, and when a chain beats a Python list.
– interview-ready · 10 questions in this topic
– of 10 tried
Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.
Questions
- How linked-list questions give you the chainPredict
- Turn a chain of links aroundOrder the steps
- Does the chain loop back on itself?Pick the fix
- Drop the k-th link from the endPredict
- Weave two sorted chains into oneFill the blank
- Fold a chain: first, last, second, second-lastPredict
- Sum two numbers stored digit by digitPredict
- Does a chain read the same backwards?Pick the fix
- The placeholder head trickSpot the bug
- When a chain beats a Python listPick the fix
Practise this topic
Flashcards · 20
Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.
Quick quiz · 10 questions
One exercise per question, checked as you go. Needs JavaScript.
Mock interview · 2 sets
Timed, out loud, then tick what you covered. Needs JavaScript.
Fix this PR · 1 review
Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.
Quick facts
Recall the answer first, then tap Show to check.
@dataclass(eq=False)With
eq=False, a dataclass keeps identity equality and hashing, so links can go in a set anda is bmeans the same link.Python
listis an arrayA Python
liststores references in one contiguous block: indexing is O(1), and inserting at the front is O(n).collections.dequedequeis built from linked blocks, so appends and pops at both ends are O(1), but indexing into the middle is O(n).Kotlin
LinkedListjava.util.LinkedListis doubly linked; in Kotlin,ArrayDequeis usually faster for queue and stack use.Recursion on long chains
A recursive walk uses one stack frame per link, so a chain longer than about 1,000 links breaks CPython's default limit.
Printable cheat sheet · Review your weak spots in this topic
Share your progress
Sources: Topic outline informed by the Tech Interview Handbook by Yangshun Tay and the NeetCode 150 pattern grouping by neetcode-gh, both MIT licensed. Every problem, solution and explanation is written by Best Latest Apps. Credits and license