Skip to main content

Coding Interview Cheat Sheets

Pattern recognition cards, complexity quick-reference, and study guides — all in one place.

321

Problems

21

Patterns

12

Cheat cards

Pattern Recognition Cards

Use these when you are unsure which pattern fits a problem.

Sliding Window

Practice →

Maintain a contiguous sub-sequence and expand/shrink from one end.

  • ✓ Longest/shortest subarray with a constraint
  • ✓ Substring problems with a frequency limit
  • ✓ Fixed-size window max/min/sum

O(n) time · O(1)–O(k) space

Two Pointers

Practice →

Use two indices to reduce an O(n²) search to O(n) on sorted or structured data.

  • ✓ Sorted array: pair sum, 3Sum, container
  • ✓ In-place modification (remove dups, move zeros)
  • ✓ Slow/fast for cycles or middle of list

O(n) time · O(1) space

Binary Search

Practice →

Halve the search space each step — works on any monotonic condition, not just arrays.

  • ✓ Sorted array or rotated sorted array
  • ✓ "Minimum X such that condition holds"
  • ✓ Search in 2D sorted matrix

O(log n) time · O(1) space

Prefix Sum

Practice →

Precompute running sums to answer range sum queries in O(1).

  • ✓ Range sum queries (immutable array)
  • ✓ Subarray sum equals k
  • ✓ Count of subarrays divisible by k

O(n) build · O(1) query

Trade space for O(1) average lookup to turn O(n²) problems into O(n).

  • ✓ Two-sum variants
  • ✓ Frequency counting / grouping
  • ✓ First/last occurrence

O(n) time · O(n) space

LIFO structure for matching, undoing, or finding the next greater/smaller element.

  • ✓ Matching brackets / nesting
  • ✓ Next greater element (monotonic stack)
  • ✓ Expression evaluation

O(n) amortized · O(n) space

BFS / Queue

Practice →

Level-order traversal; guarantees shortest path in unweighted graphs.

  • ✓ Shortest path (unweighted)
  • ✓ Level-by-level tree traversal
  • ✓ Multi-source spread (rotting oranges)

O(V + E) time · O(V) space

Heap / Priority Queue

Practice →

Always access the min or max in O(log n); ideal for k-th element and scheduling.

  • ✓ Kth largest/smallest element
  • ✓ Merge k sorted lists/streams
  • ✓ Task scheduling / rearrangement

O(n log k) time · O(k) space

Dynamic Programming

Practice →

Break into overlapping sub-problems. Define state → recurrence → base case → optimise.

  • ✓ Optimal value (min cost, max profit)
  • ✓ Count of ways
  • ✓ "Can we achieve X?" yes/no

O(n²) typical · O(n)–O(n²) space

DFS / Backtracking

Practice →

Explore all paths; prune branches that can never lead to a valid solution.

  • ✓ All subsets / permutations / combinations
  • ✓ Word search in a grid
  • ✓ N-queens, Sudoku

O(2ⁿ) or O(n!) · O(n) recursion stack

Union-Find

Practice →

Near-O(1) union and find for dynamic connectivity problems.

  • ✓ Connected components (dynamic)
  • ✓ Cycle detection (undirected)
  • ✓ Merging groups (accounts merge)

O(α(n)) per op · O(n) space

Topological Sort

Practice →

Linear ordering of vertices in a DAG — detect cycles and find dependency order.

  • ✓ Course scheduling / prerequisites
  • ✓ Build order / dependency resolution
  • ✓ Detect cycles in directed graph

O(V + E) time · O(V) space

Time Complexity Quick Reference

Interview target for n = 10⁶: aim for O(n log n) or better.

Complexity Type
O(1) Constant
O(log n) Logarithmic
O(n) Linear
O(n log n) Log-linear
O(n²) Quadratic
O(2ⁿ) Exponential
O(n!) Factorial

Pattern Decision Tree

When you see these keywords in a problem, reach for the corresponding pattern.

Keyword / constraint Pattern to try first
Longest / smallest subarray with constraint Sliding Window
Sorted array, pair sum, in-place removal Two Pointers
"Minimum X satisfying condition" with large range Binary Search on Answer
Range sum query, subarray sum = k Prefix Sum + Hash Map
Shortest path, minimum steps, level-by-level BFS
All paths, all subsets/permutations, Sudoku DFS / Backtracking
Kth largest, merge k sorted, task schedule Heap
Max/min value with sub-problems, count of ways Dynamic Programming
Prerequisites, dependency order, build system Topological Sort
Brackets matching, next greater element Monotonic Stack
Connected groups, dynamic connectivity Union-Find
Prefix matching, autocomplete, word dictionary Trie

Featured Architecture & Interview Deep Dives

🏗️ Architecture Reference

System Design Cheat Sheet: Latency & Math Guide

Latency numbers every engineer should know, back-of-the-envelope capacity estimations, database selection matrices, and printable 1-page layout.

View Cheat Sheet →
📐 Software Design

LLD vs HLD: Low-Level vs High-Level Design Compared

Key differences side-by-side, interview round expectations, design patterns vs distributed architectures, and concrete interview examples.

Read Comparison →
🟠 FAANG Behavioral

Amazon Leadership Principles: 60+ Real Interview Questions

All 16 Amazon LPs covered with real interview questions, STAR method model answers, Bar Raiser scoring secrets, and the 6-story prep matrix.

Explore All 16 Principles →
🤖 AI Engineering Tools

10 Best AI Code Review Tools in 2026: Tested & Ranked

Benchmarked comparison of CodeRabbit, Copilot, Qodo, Snyk, and PR-Agent across review speed, noise suppression, and AST analysis.

Compare Tools →
⭐ Open Source Excellence

Top 30 GitHub Resource Collections (CS Core & Placements)

Curated free repositories for full CS degree curriculums, campus placements, university lecture slides, Linux kernel source code, and low-level system design.

Curriculum OSSU

📁 computer-science

A complete free CS degree curriculum with ordered courses

Best for: Studying CS properly rather than in fragments
GitHub ↗
Placement collection Anushka Gupta

📁 Complete-Placement-Preparation

DSA, CS core, aptitude and HR preparation for Indian placements

Best for: The most India-specific placement repository
GitHub ↗
Question bank Community

📁 Interview-Prepartion-Data-Structures-Algorithms-CS-Core

CS core subject questions organised by topic

Best for: Subject-wise revision
GitHub ↗
Study plan John Washam

📁 coding-interview-university

A multi-month CS study plan covering OS, networks and databases

Best for: Filling fundamentals gaps systematically
GitHub ↗
Interview prep Yangshun Tay

📁 tech-interview-handbook

Interview process, algorithms, behavioural and resume guidance

Best for: The whole job hunt in one place
GitHub ↗
Question bank DopplerHQ

📁 awesome-interview-questions

Interview questions indexed by subject and technology

Best for: Rapid revision across subjects
GitHub ↗
Resource index EbookFoundation

📁 free-programming-books

Thousands of free books and courses including all four CS core subjects

Best for: The broadest free learning index that exists
GitHub ↗
Course index Developer-Y

📁 cs-video-courses

Thousands of university CS courses indexed by subject

Best for: University-grade OS, DBMS and networking lectures
GitHub ↗
Curated collection Aflah Bhat

📁 SemWiseResourcesIIIT

Semester-wise course resources from IIIT Delhi

Best for: Following an actual university syllabus
GitHub ↗
Course index Prakhar1989

📁 awesome-cs-courses

University CS courses with assignments and materials

Best for: Course material from top universities
GitHub ↗
Reference implementation MIT PDOS

📁 xv6-public

A small teaching operating system you can actually read

Best for: Understanding an OS by reading its source
GitHub ↗
Awesome list Jubalh

📁 awesome-os

Operating system development resources and reading

Best for: Going deeper than the syllabus
GitHub ↗
Tutorial Carlos Fenollosa

📁 os-tutorial

Build a minimal operating system from scratch, step by step

Best for: Learning OS by building one
GitHub ↗
Awesome list Peter Zaitsev / community

📁 awesome-database-learning

Database internals, papers and learning material

Best for: DBMS beyond the syllabus
GitHub ↗
Style guide Simon Holywell

📁 sql-style-guide

Readable, consistent SQL conventions

Best for: SQL a reviewer can follow
GitHub ↗
Awesome list Asad Dhamani

📁 awesome-postgres

PostgreSQL tools, extensions and learning resources

Best for: The database you will most likely use
GitHub ↗
Awesome list Community

📁 awesome-computer-networking

Networking learning resources, tools and references

Best for: Networking depth beyond the syllabus
GitHub ↗
Project collection CodeCrafters

📁 build-your-own-x

Build your own OS, database, network stack and shell

Best for: Understanding these subjects by building them
GitHub ↗
LLD collection Ashish Pratap Singh

📁 awesome-low-level-design

Object-oriented design problems with solutions and diagrams

Best for: The OOP round asked at Amazon and Indian companies
GitHub ↗
LLD reference Prasad Gujar

📁 low-level-design-primer

OOP design problems, patterns and worked solutions

Best for: Structured OOP design preparation
GitHub ↗
Pattern collection Ilkka Seppala

📁 java-design-patterns

Every classic design pattern implemented and explained

Best for: The patterns asked by name in OOP rounds
GitHub ↗
Interview prep Avinash Singh (Let's Code)

📁 Awesome-DSA-Resource

Curated DSA resources; the round that runs alongside CS core

Best for: The coding round in the same process
GitHub ↗
Interview prep Donne Martin

📁 system-design-primer

System design concepts; CS core is its foundation

Best for: Where these subjects lead next
GitHub ↗
Roadmap collection Kamran Ahmed

📁 developer-roadmap

Interactive computer science and subject-specific roadmaps

Best for: Seeing the whole path on one page
GitHub ↗
Reference collection Michael Nagi

📁 every-programmer-should-know

Concepts every developer should eventually understand

Best for: Finding the gaps you did not know you had
GitHub ↗
Cheat sheet collection LeCoupa

📁 awesome-cheatsheets

Cheat sheets for languages, tools and concepts

Best for: Rapid recall before an interview
GitHub ↗
Curated collection Community

📁 Placement-Preparation-Resources

Indian placement resources across CS core, DSA and aptitude

Best for: Campus placement specifically
GitHub ↗
Reference collection Charles-Axel Dein

📁 professional-programming

A large curated reading list for professional practice

Best for: Growing beyond exam-style knowledge
GitHub ↗
Paper index Papers We Love

📁 papers-we-love

Foundational CS papers by topic

Best for: The research behind the textbooks
GitHub ↗
Resource index ripienaar

📁 free-for-dev

Free tiers of cloud, database and hosting services

Best for: Practising these subjects on real infrastructure
GitHub ↗

Ready to practice?

Apply these patterns to real problems with difficulty filters and progress tracking.

Buy me a coffee
Daily Practice
0/0