Skip to main content

Core Patterns for Coding Interview Preps

Core patterns are reusable problem-solving templates such as two pointers, sliding window, prefix sums, binary search and backtracking. Recognising which pattern a problem fits lets you skip inventing a method from scratch. They form the first technical stage of interview prep and apply mainly to arrays, strings and recursive search.

Stage: Patterns · Part of the Coding Interview Prep roadmap · Last reviewed 19 November 2026

What to learn in Core Patterns

Core Patterns interview questions

When should you use a sliding window instead of nested loops?

Use it when the problem asks about a contiguous subarray or substring and the window can be updated incrementally as it moves. It reduces an O(n^2) check of every range to O(n), because each element enters and leaves the window at most once.

What makes a problem suitable for binary search on the answer?

The answer lies in a numeric range and a yes/no feasibility check is monotonic: if a value works, all larger (or smaller) values also work. You then binary search the range and use the check function to move the bounds, as in minimum capacity or shipping-days problems.

Where Core Patterns fits in the Coding Interview Prep roadmap

Core Patterns belongs to the Patterns stage (intermediate level), which takes about 27 hours. Core techniques.

Back to the full Coding Interview Prep roadmap