Interview Questions, Answered by Running Them

The questions actually asked about strings, lists and dictionaries - each with the code, run in your browser.

49 modules Free, no login Updated 9 September 2026

About this track

Interview answers are not recall problems. "Why is this O(n²)?" is answered properly by showing the count, and "which is faster?" by measuring both - which is what every page here does. Each question gets its own page: the answer in prose, a visualisation that steps through the mechanism, and a real Python interpreter with the implementation already in it.

The track is organised the way the questions are asked - strings, then lists and arrays, then dictionaries, hashing and the complexity traps that catch most candidates. Conceptual questions and coding problems sit side by side, because interviews mix them.

Every other track is organised around ideas. This one is organised around questions, because that is the shape the pressure arrives in: someone asks why your loop is quadratic, and you have thirty seconds. Each page is one question, answered in full and then demonstrated by code you can run.

What you will be able to do

  • Answer the immutability, hashability and complexity questions without hedging.
  • Reach for the right technique on sight - two pointers, sliding window, prefix sums, a counter.
  • State the time and space cost of your own solution before being asked for it.
  • Recognise the traps: `in` on a list, `+=` on a string, `pop(0)` as a queue.
  • Show your working - the pages measure their claims, and so can you.

How the track is ordered

The track runs strings, then lists and arrays, then dictionaries, hashing and the crossover problems, finishing on the complexity traps. Within each group the conceptual questions come before the coding problems that lean on them, because "why is `in` slow on a list?" is the answer to half the coding questions that follow it. Nothing here assumes you have read the rest of the site, though the algorithms track covers the same techniques at more length.

Where this leads

The Algorithms and Data Structures track is the long-form version of this one: same techniques, one page per algorithm rather than one page per question, with the visualisation carrying more of the explanation. If a question here lands on something unfamiliar - binary search bounds, hash collisions, dynamic programming - that track has the full treatment.

All 49 modules, in teaching order

  1. 01Why are Python strings immutable?
  2. 02What does slicing a string cost?
  3. 03Does len() count characters or bytes?
  4. 04What is the difference between str and bytes?
  5. 05Why does `is` sometimes work on strings?
  6. 06find() vs index() vs `in` — which one?
  7. 07Reverse a string
  8. 08Check whether a string is a palindrome
  9. 09Are two strings anagrams?
  10. 10Group anagrams together
  11. 11Longest substring without repeating characters
  12. 12First non-repeating character
  13. 13Valid parentheses
  14. 14Run-length string compression
  15. 15Longest common prefix
  16. 16Implement substring search (strStr)
  17. 17Isomorphic strings
  18. 18Longest palindromic substring
  19. 19Edit distance (Levenshtein)
  20. 20Minimum window substring
  21. 21What is a Python list underneath?
  22. 22Why does [[0]*3]*3 break?
  23. 23Why is `in` slow on a list but fast on a set?
  24. 24Two Sum
  25. 25Maximum subarray sum (Kadane)
  26. 26Remove duplicates from a sorted array in place
  27. 27Rotate an array by k
  28. 28Product of array except self
  29. 29Merge overlapping intervals
  30. 30Find the duplicate number
  31. 31Kth largest element
  32. 32Trapping rain water
  33. 33Sort an array of 0s, 1s and 2s
  34. 343Sum
  35. 35Search in a rotated sorted array
  36. 36Sliding window maximum
  37. 37list vs tuple vs deque vs array — which and why?
  38. 38How does a Python dict work?
  39. 39Why must dictionary keys be hashable?
  40. 40Count things with a dictionary
  41. 41What is the complexity of this code?
  42. 42Design an LRU cache
  43. 43Longest consecutive sequence
  44. 44Subarray sum equals k
  45. 45When should you use a set instead of a list?
  46. 46What happens if you modify a collection while looping over it?
  47. 47Memoisation: caching with a dictionary
  48. 48Implement a hash map from scratch
  49. 49Group records and invert a dictionary

Other tracks