← Back to all products
$29
Coding Patterns Quick Reference
15 essential coding patterns (sliding window, two pointers, BFS/DFS, dynamic programming) with Python and JavaScript solutions.
JSONMarkdownPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 26 files
coding-patterns-reference/
├── LICENSE
├── README.md
├── cheatsheets/
│ ├── complexity-reference.md
│ └── pattern-selection-guide.md
├── patterns/
│ ├── 01-sliding-window.md
│ ├── 02-two-pointers.md
│ ├── 03-fast-slow-pointers.md
│ ├── 04-merge-intervals.md
│ ├── 05-cyclic-sort.md
│ ├── 06-in-place-reversal.md
│ ├── 07-bfs.md
│ ├── 08-dfs.md
│ ├── 09-two-heaps.md
│ ├── 10-subsets.md
│ ├── 11-binary-search-modified.md
│ ├── 12-bitwise-xor.md
│ ├── 13-top-k-elements.md
│ ├── 14-k-way-merge.md
│ └── 15-dynamic-programming.md
├── solutions/
│ ├── README.md
│ ├── binary_search.py
│ ├── dynamic_programming.py
│ ├── graph_traversal.py
│ ├── sliding_window.py
│ └── two_pointers.py
└── study-plan/
└── coding-prep-plan.md
📖 Documentation Preview README excerpt
Coding Patterns Quick Reference
15 essential coding patterns with 60+ fully solved problems in Python and JavaScript.
Master the patterns that appear in 95% of technical interviews.
What's Inside
| Directory | Contents |
|---|---|
patterns/ | 15 in-depth pattern guides with 3-4 solved problems each |
cheatsheets/ | Pattern selection guide + Big-O complexity reference |
solutions/ | Runnable Python files with test cases for core patterns |
study-plan/ | 4-week structured preparation plan |
Pattern Index
| # | Pattern | Difficulty | Key Signal |
|---|---|---|---|
| 01 | [Sliding Window](patterns/01-sliding-window.md) | Easy-Medium | Contiguous subarray/substring, fixed or variable size |
| 02 | [Two Pointers](patterns/02-two-pointers.md) | Easy-Medium | Sorted array, pair finding, partitioning |
| 03 | [Fast & Slow Pointers](patterns/03-fast-slow-pointers.md) | Medium | Cycle detection, linked list middle/nth node |
| 04 | [Merge Intervals](patterns/04-merge-intervals.md) | Medium | Overlapping intervals, scheduling |
| 05 | [Cyclic Sort](patterns/05-cyclic-sort.md) | Medium | Numbers in range [0, n] or [1, n], missing/duplicate |
| 06 | [In-Place Reversal](patterns/06-in-place-reversal.md) | Medium | Reverse linked list or sub-list in-place |
| 07 | [BFS](patterns/07-bfs.md) | Medium | Level-order traversal, shortest path (unweighted) |
| 08 | [DFS](patterns/08-dfs.md) | Medium | Tree paths, graph exploration, backtracking |
| 09 | [Two Heaps](patterns/09-two-heaps.md) | Medium-Hard | Find median, split into two halves |
| 10 | [Subsets](patterns/10-subsets.md) | Medium | Generate permutations, combinations, power set |
| 11 | [Modified Binary Search](patterns/11-binary-search-modified.md) | Medium | Sorted/rotated array, find boundary, answer space |
| 12 | [Bitwise XOR](patterns/12-bitwise-xor.md) | Medium | Find single/missing numbers without extra space |
| 13 | [Top K Elements](patterns/13-top-k-elements.md) | Medium | Kth largest/smallest, most frequent |
| 14 | [K-Way Merge](patterns/14-k-way-merge.md) | Hard | Merge K sorted lists, external sort |
| 15 | [Dynamic Programming](patterns/15-dynamic-programming.md) | Hard | Optimization over overlapping subproblems |
Recommended Study Order
Study patterns in this order, grouped by difficulty:
Week 1 — Foundation Patterns (build intuition)
1. Sliding Window
2. Two Pointers
3. Modified Binary Search
Week 2 — Linked List & Array Patterns
4. Fast & Slow Pointers
5. In-Place Reversal
6. Merge Intervals
7. Cyclic Sort
Week 3 — Tree, Graph & Combinatorial Patterns
8. BFS
9. DFS
10. Subsets
11. Bitwise XOR
Week 4 — Advanced Patterns
12. Two Heaps
13. Top K Elements
14. K-Way Merge
15. Dynamic Programming
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
solutions/binary_search.py
"""
Modified Binary Search Pattern — Runnable Solutions
=====================================================
Problems solved:
1. Search in Rotated Sorted Array
2. Find Minimum in Rotated Sorted Array
3. Find First and Last Position of Target
4. Find Peak Element
Reference: patterns/11-binary-search-modified.md
Run: python3 solutions/binary_search.py
Requires: Python 3.10+, no external dependencies.
"""
from __future__ import annotations
# ---------------------------------------------------------------------------
# Problem 1: Search in Rotated Sorted Array
# ---------------------------------------------------------------------------
def search_rotated(arr: list[int], target: int) -> int:
"""Search for target in a rotated sorted array (all values distinct).
Approach — Modified binary search:
At any midpoint in a rotated sorted array, at least one half (left or
right of mid) is guaranteed to be properly sorted.
1. Compare arr[left] with arr[mid] to determine which half is sorted.
2. Check if the target falls within the sorted half's range.
3. If yes, search that half. If no, search the other half.
Why it works: the unsorted half contains the rotation point, but the
sorted half lets us make a definitive inclusion/exclusion decision.
Time: O(log n)
Space: O(1)
"""
left, right = 0, len(arr) - 1
while left <= right:
mid = left + (right - left) // 2
if arr[mid] == target:
return mid
# Left half is sorted
if arr[left] <= arr[mid]:
# ... 234 more lines ...