The cover of Think in Patterns: a chalkboard with the letters D, S and A drawn from data structures, the title, and Ravi Teja K's name

A Hootshell notebook · for Python coding interviews

Think in Patterns

The Python Coding Interview Notebook

Don’t memorise 340 problems. Learn the 36 patterns behind them.

Coding interviews look endless. Look closer and the same few dozen ideas keep coming back in new clothes. This notebook teaches you to see them, one patient page at a time.

$29₹699Regular price:$39₹999Save 26%Save 30%₹699 in India

Buy the PDF · $29₹699Test checkout: no real moneyRead 42 pages free

Short on time? Route B is 57 problems that cover every classic pattern at least once: at three a day, under three weeks.

A PDF for any screen · 7-day refund · Edition 1.1, November 2026

  • 340problems: 300 classic and 40 AI-era
  • 36patterns, one chapter each
  • 13Foundations topics for beginners
  • 913answers, each linked from its exercise and back
  • 353Python solution files, run against their tests before release

The problems are free online. Why a book?

A fair question. Here is the plain answer.

  • A list gives you questions. This gives you the idea behind them. 340 problems sorted into 36 patterns, each with the words that give it away, so the next problem you have never seen still looks familiar.
  • One patient voice, start to finish. Every problem is taught the same way: an everyday scene, the obvious answer, the better one, a drawing, tested Python, why it works, a dry run and the mistakes people make.
  • You do part of the work. Questions to predict, dry runs to finish and twists to try, with every one of the 913 answers one link away.
  • A route, so you always know what is next. Short on time? Route B is 57 problems that cover every classic pattern at least once: at three a day, under three weeks.
  • Checked before it reaches you. Every one of the 353 Python solution files runs against its tests before a release.

And you can check all of it before paying: read 42 pages free, try the free lessons, and if you buy and it is not for you, there is a 7-day refund.

One problem, start to finish

Every problem starts with a scene you already know, like raffle tickets at a school fair. The code comes after.

  1. An everyday sceneThe problem told as something you already know.
  2. The obvious answerBrute force first, and what it costs.
  3. The better oneThe idea that removes the wasted work.
  4. A drawingThe key moment, drawn by hand.
  5. PseudocodeThe plan in plain words.
  6. Tested PythonReadable code that runs against its tests.
  7. Why it worksThe reason, not only the steps.
  8. A dry runThe code traced on a small input.
  9. The mistakes people makeThe traps, before you fall in.

Step 8 for yourself: a dry run

From Contains Duplicate, the raffle-ticket problem: walk the tickets once, keep a set of the numbers seen, and stop at the first repeat.

  1. 140
  2. 31
  3. 92
  4. 273
  5. 34
At the last ticket: seen = {14, 3, 9, 27}, and 3 is already in it → True

Read the whole problem free →

And you do part of the work

Reading a solution feels like understanding it. These three make sure it is.

  • Predict first

    One question to answer before you read on. The next sections tell you if you were right.

  • Your turn

    After the dry run, run the method by hand on a new input. The → answer link takes you there and ↩ brings you back.

  • A twist to try

    The same problem with one rule changed. Adapt the solution yourself, then check its answer.

Every answer is printed at the end of its chapter, never next to its question, so you can’t peek by accident.

You don’t read 2,288 pages. You follow a route.

Nobody reads it cover to cover. Pick a route, and one problem per sitting is plenty.

Each route has its own page in the book. Every step on it is a link, so you always know what to read next and when you are ready to move on.

  • Route A · Foundations first

    Take it if data structures are new to you, or “hash map” and “O(n log n)” still feel vague.

    It starts with the 13 Foundations topics: what each structure is, what it costs and where real software uses it. About two weeks at one topic a day.

  • Route B · Interview core

    Take it if you know the basic structures and have an interview coming.

    57 problems that unlock the most others, covering every classic pattern at least once. At three a day, under three weeks.

  • Route C · Applied (AI-era)

    Take it if you are aiming at ML, data, backend or AI-agent roles.

    The core problems the applied chapters build on, then the six applied chapters: NumPy, pandas, embeddings, APIs, async code and AI agents.

Not sure? Try the first problem without reading its solution. If you can’t write working code in 20 minutes, take route A. If the answer comes to you quickly, take route B.

What you need before page 1: basic Python (variables, if, for and while loops, functions, lists and dicts, running a .py file). No maths beyond school algebra, and no computer-science degree.

Look inside

Nine pages from the book, exactly as printed. Turn them as you would the real thing, and open one larger to read it.

The page "Three ways through this book": what you need before page 1, a table of the three routes, and how the book checks you
The Route B page: who it is for, what you can do after it, the interview toolkit, and the first core problems with their page numbers

p. 13 · Three ways through the book, and what you need before page 1p. 17 · Route B: the 57-problem Interview core, every step with its page

All nine pages at once
  • The opening page of the problem Contains Duplicate: a raffle-ticket story, two examples, questions to clarify first, and a Predict first box
    p. 134 · A problem opens with an everyday scene: raffle tickets at a school fair
  • A Two Sum page: the brute-force code, then the idea of a notebook of numbers seen, with a drawing of the list and the current index
    p. 150 · Two Sum: from trying every pair to remembering what you have seen
  • A page with Why it works, a dry-run table, a Your turn exercise linking to its answer, a complexity table and edge cases
    p. 137 · Why it works, a dry run, and a Your turn with its answer page
  • A Foundations page on hash maps, with a drawing of keys going through a hash function into numbered lockers
    p. 54 · Foundations: a hash map explained as a wall of lockers
  • The page "Three ways through this book": what you need before page 1, a table of the three routes, and how the book checks you
    p. 13 · Three ways through the book, and what you need before page 1
  • The Route B page: who it is for, what you can do after it, the interview toolkit, and the first core problems with their page numbers
    p. 17 · Route B: the 57-problem Interview core, every step with its page
  • An answers page for chapter 1, Arrays and Hashing, where each answer ends with a link back to its page
    p. 232 · The answers for chapter 1, each with a link back to its exercise
  • The opening page of the AI-era problem Scaled Dot-Product Attention, with a meeting analogy and two worked examples
    p. 1996 · AI-era: scaled dot-product attention, explained as a meeting
  • A Mixed practice page: short everyday stories, each hiding a problem from the book, to practise spotting the pattern
    p. 2250 · Mixed practice: problems in new clothes, with no chapter to give them away

What’s inside

Every one of the 353 solution files runs against its tests before release, on Python 3.14, and is checked on 3.12 too.

The 36 patterns

300 classic interview problems in 30 patterns, then 40 AI-era problems in 6 more. The number is how many problems each chapter has.

Arrays, Strings & Hashing49 problems

  1. 1Arrays & Hashing19
  2. 2Prefix Sum & Difference Array8
  3. 3Cyclic Sort4
  4. 4Matrix & Grid5
  5. 5Strings & Pattern Matching13

Two Pointers & Sliding Window27 problems

  1. 6Two Pointers15
  2. 7Sliding Window12

Searching & Sorting20 problems

  1. 8Binary Search15
  2. 9Sorting & Quickselect5

Linked Lists17 problems

  1. 10Linked List12
  2. 11Fast & Slow Pointers5

Stacks & Queues25 problems

  1. 12Stack13
  2. 13Monotonic Stack & Queue12

Trees32 problems

  1. 14Binary Trees (DFS & BFS)21
  2. 15Binary Search Trees6
  3. 16Tries5

Heaps14 problems

  1. 17Top-K, Two Heaps, K-way Merge14

Graphs31 problems

  1. 18Graph BFS & DFS15
  2. 19Topological Sort5
  3. 20Union-Find5
  4. 21Shortest Paths & MST6

Recursion & Backtracking14 problems

  1. 22Backtracking14

Dynamic Programming32 problems

  1. 231-D Dynamic Programming13
  2. 242-D Dynamic Programming12
  3. 25Knapsack & Interval DP7

Greedy & Intervals17 problems

  1. 26Intervals7
  2. 27Greedy10

Math & Bits15 problems

  1. 28Bit Manipulation7
  2. 29Math & Geometry8

Design7 problems

  1. 30Data-Structure Design7

Applied & AI-era coding40 problems

  1. 31NumPy & ML Coding8
  2. 32Pandas & Data Engineering7
  3. 33Embeddings & Retrieval6
  4. 34APIs & Backend Patterns6
  5. 35Async & Concurrency6
  6. 36AI Agent Patterns7

Around the problems

Everything else that turns 340 problems into a course.

  • 13 Foundations topics

    For beginners: What DSA is, and why interviews ask it · Big-O without fear · Memory, variables and references · Arrays and Python lists · Strings · Hash maps · Linked lists · Stacks and queues · Recursion · Sorting and searching · Trees · Heaps and priority queues · Graphs.

  • The interview toolkit

    The six steps to follow out loud in every interview, a cheat sheet from the words in a problem to its pattern, Big-O and Python at a glance, and what to expect in online assessments.

  • Interviews in the AI era

    How AI-assisted rounds work, and what to check in an assistant’s code. Then 40 applied problems: NumPy, pandas, embeddings, APIs, async code and AI agents.

  • Practice that sticks

    A checkpoint after every chapter, 4 mixed practice sets, 4 timed coding rounds and 6 projects.

  • Plans and a tracker

    8-week and 14-day plans, and a tracker with re-solve dates at 3, 10 and 30 days.

    Solved it once? Solve it again after 3, 10 and 30 days.

  • A fully linked PDF

    2,288 A4 pages with contents, index, every “see page” reference and bookmarks for every chapter and problem. Plus 36 chapter PDFs, each with its own answers, handy on a phone.

Try 42 pages free

Not sure yet? Read the sample first. No email, no sign-up.

The free sample · 42 pages

The three routes through the book, one Foundations topic (hash maps) and the first problems of chapter 1 with their answers, links and all.

Or download the PDF (1.3 MB) to keep.

Who it’s for

  • For you if

    You know basic Python (loops, functions, lists, dicts) and want to pass coding interviews: students, career changers and working developers. No computer-science degree needed.

  • What it is not

    Not a system-design or behavioural-interview book. Not a promise of a job or an interview result. Not affiliated with LeetCode or any company named in it: LeetCode numbers are there only so you can find each problem to practise on.

Get the notebook

$29₹699Regular price:$39₹999Save 26%Save 30%₹699 in India

Launch price. The regular price, $39₹999, starts after 31 January 2027. One-time purchase, no subscription.

The checkout charges the price for the country you buy from: the rupee price in India, the US-dollar price everywhere else (your checkout may show it converted into your own currency). Tax is included in the price. Checkout by Dodo Payments, the merchant of record; they email your download link right after you pay. All pricing

  • The whole book: one fully linked A4 PDF, 2,288 pages
  • 36 chapter PDFs, each with its own answers
  • Works on any laptop, tablet or phone
  • One zip, about 91 MB
  • Corrected 1.x editions free
  • Your money back within 7 days if it’s not for you

Questions

The problems are free online. Why pay?

A problem list gives you questions. The book gives you the 36 ideas behind them, taught in one voice, with a drawing, tested code, a dry run and an exercise with its answer on every problem, and a route so you know what to do next. The longer answer.

Which Python do I need?

3.12 or newer. The solutions use the standard library, plus NumPy and pandas in two applied chapters.

How do I get the book after paying?

Dodo Payments emails you, usually within a few minutes: a receipt and a link to your download page, where the zip is. That link works for 30 days. After that, or on another device, the customer portal sends you a fresh one: type the email you paid with.

Lost your download?

Open the customer portal and enter the email you bought with: it sends a fresh download link. That page never expires, so it works years later too.

Is tax included?

Yes. The price you see is the price you pay; any tax is inside it.

Can I read it on my phone?

Yes. The whole book is one A4 PDF, and each chapter is also its own PDF with its answers, which is easier on a small screen.

Can I print it?

Yes, for yourself. The licence is on page 5.

Is it on Kindle?

Not yet. For now it is a PDF.

Will it be updated?

Corrections go on the public corrections page, and buyers get corrected editions of 1.x free. What changed in each edition.

Why are company names on some problems?

They come from public interview-question lists and candidates’ reports. They show how widely a problem is reported, not that a company uses it.

What if it isn’t for me?

Email contact@proserviq.com within 7 days of buying for a full refund. How refunds work.

About the author

Asks why. Proves it. Then finds a better way.

I studied electronics at NIT Goa and finance at business school, then spent two and a half years at a global bank automating payment operations and doing my first machine learning and data work: fraud-detection models, data pipelines and analytics dashboards. From there I moved into AI full time. Today I’m a senior AI/ML engineer and solution architect. My work is taking messy processes nobody fully understands, finding the rule hidden inside, and rebuilding them so every number has a reason and every result is tested. I wrote this book the same way: ask why a solution works, prove it, then look for a better one.

Ravi Teja K

Made the cut among a million · AI/ML solution architect

Elsewhere: LinkedIn

Buy the PDF · $29₹699Test checkout: no real moneyRead 42 pages free