Patterns Before Problems

Patterns Before Problems
Ebook · Instant Download
You can find a working solution to any DSA problem in thirty seconds of searching. What is much harder to find is an answer to the question you actually have at 11pm on a Tuesday, staring at a problem you cannot start:

how was I supposed to know that was binary search?

That is the gap this book fills.

Every problem is laid out the same way — and the code comes last.

The idea in one line. If you read nothing else, read this.

The problem, in plain language, with only the details that change how you solve it.

Why it works, explained from the beginning, usually walked through by hand with real numbers.

How to recognise it. The most useful part: which words in the question should have pointed you here.

Pseudocode. The steps in plain English, no programming language needed.

Java. The solution you would actually write in an interview, with how fast it runs.

What's inside

291 problems across 17 topics — arrays, binary search, strings, linked lists, recursion, bit manipulation, stacks, sliding window, heaps, greedy, trees, BSTs, graphs, dynamic programming and tries.

A one-page table that tells you which technique to use. For each technique it lists the words to look for in a problem. For example: if a problem says "contiguous" and asks for the longest or shortest something, that is a sliding window. There are 24 of these, and they are the fastest way to get unstuck.

How to read the constraints. If a problem says the input can be 100,000 items, that one line already tells you roughly how fast your solution has to be — and rules out most approaches before you start. There is a table for working this out.

A chapter on Java's own traps — the things that cost you marks even when your algorithm is right. Why `ArrayDeque` beats `Stack`. Why `list.remove(1)` deletes position 1 rather than the number 1. Why `(lo + hi) / 2` is a bug that sat inside Java itself for nine years.

Binary search on the answer, in its own chapter. Most people only learn to binary search a sorted list. The more useful version searches for a number — "what is the slowest speed that still finishes in time?" — and it comes up constantly.

Dynamic programming taught as four patterns, not 34 separate solutions. Once you can tell which of the four you are looking at, the code follows.

A plan for the two weeks before an interview — what to re-solve, how to practise explaining yourself while you code, and what to write down each time you get stuck.

Why this one

Written for beginners on purpose. Every technique is explained from the start. Nothing assumes you already know what a monotonic stack is.

Every Java solution was compiled, not just proofread. A script pulls all 295 of them out of the book and builds them before it ships. If it did not compile, it did not go in.

Problems that look different but are the same are shown together. Koko eating bananas, shipping packages in D days, allocating books to students and the painter's partition problem are one problem with four different stories. The book shows you the connection instead of teaching four solutions.

Aimed at Indian product companies, bank tech centres and funded startups. A few famous algorithms are left out on purpose, because they rarely come up at that level. Where that happens, the book tells you what the algorithm does — so you can still say something sensible if it ever appears.

Who it's for

Engineers with 0–10 years of experience preparing for coding rounds, and anyone working through a six-month DSA plan who wants the reasoning written down rather than another list of solutions.

What you get

  • 359-page PDF, instant download
  • Lifetime access, plus free updates to this edition
  • Reads on any device

First Edition · August 2026 · Ankush Kumar
549659