💻Pro

Grokking the Coding Interview: Patterns in Python

Master 16 essential coding patterns to solve any interview question. Each pattern includes detailed explanations, visual walkthroughs, and hands-on Python exercises with an in-browser IDE.

12 modules 86 lessons ~22h AI voice coach
Start Learning — Pro

7-day free Pro trial included

Course Outline

1

Two Pointers Pattern

7 lessons

Master the two-pointer technique for solving problems involving sorted arrays, pair sums, and in-place manipulation with O(n) time complexity.

Introduction to the Two Pointers Pattern
Pair with Target Sum
Remove Duplicates from Sorted Array
Squaring a Sorted Array
Triplet Sum to Zero (3Sum)
Dutch National Flag (Sort Colors)
Checkpoint: Two Pointers Mastery
2

Fast & Slow Pointers (Floyd's Algorithm)

7 lessons

Use two pointers moving at different speeds to detect cycles, find midpoints, and identify structural properties in linked lists and arrays.

Introduction to Fast & Slow Pointers
Linked List Cycle Detection
Start of LinkedList Cycle
Happy Number
Middle of the LinkedList
Palindrome LinkedList
Checkpoint: Fast & Slow Pointers Review
3

Sliding Window Pattern

8 lessons

Efficiently process contiguous subarrays and substrings by maintaining a dynamic window that expands and contracts instead of recomputing from scratch.

Introduction to Sliding Window
Maximum Sum Subarray of Size K
Smallest Subarray with a Target Sum
Longest Substring with K Distinct Characters
Longest Substring After Character Replacement
Permutation in a String (Anagram Search)
Minimum Window Substring (Hard)
Checkpoint: Sliding Window Mastery
4

Merge Intervals Pattern

7 lessons

Solve scheduling, calendar, and range-overlap problems by sorting intervals and merging or inserting them with a sweep-line approach.

Introduction to the Merge Intervals Pattern
Merge Overlapping Intervals
Insert Interval
Intervals Intersection
Minimum Meeting Rooms (Conflicting Appointments)
Employee Free Time
Checkpoint: Intervals Pattern Review
5

Cyclic Sort & In-Place LinkedList Reversal

8 lessons

Sort arrays containing numbers in a known range in O(n) by placing each element at its correct index, and reverse linked list substructures without extra space.

Introduction to Cyclic Sort
Find the Missing Number
Find All Duplicates and Missing Numbers
Introduction to In-Place LinkedList Reversal
Reverse a Sub-list (Positions p to q)
Reverse Every K-Element Sub-list
Rotate a LinkedList
Checkpoint: Cyclic Sort & Reversal Practice
6

Tree BFS & DFS Traversal Patterns

8 lessons

Navigate binary trees and n-ary trees using level-order BFS (queue-based) and path-tracking DFS (stack/recursion) to solve a broad class of tree problems.

Introduction to Tree BFS (Level-Order Traversal)
Level-Order & Reverse Level-Order Traversal
Zigzag Level-Order Traversal
Introduction to Tree DFS
Path Sum, All Paths for a Sum & Sum of Path Numbers
Tree Diameter & Maximum Path Sum
Binary Tree Right View & Connect Level Nodes
Checkpoint: BFS vs DFS Decision & Practice
7

Two Heaps & Top K Elements

7 lessons

Use min-heaps and max-heaps to efficiently track medians, running statistics, and the K most extreme elements in dynamic data streams.

Python heapq Primer & Heap Invariants
Top K Numbers & Kth Largest Element
K Closest Points to Origin
Introduction to Two Heaps: Find Median from Data Stream
Sliding Window Median
Task Scheduler & Reorganize String
Checkpoint: Heap Pattern Mastery
8

Subsets/Backtracking & Modified Binary Search

7 lessons

Generate all subsets, permutations, and combinations using BFS-style expansion or recursive backtracking, and extend binary search beyond simple lookup to rotated arrays and boundary problems.

Introduction to Subsets Pattern (BFS Expansion)
Subsets with Duplicates & Permutations
Generate Balanced Parentheses
Introduction to Modified Binary Search
Search in Rotated Sorted Array
Find First and Last Position (Bisect Left/Right)
Checkpoint: Subsets & Binary Search Practice
9

K-Way Merge & Bitwise XOR

7 lessons

Efficiently merge multiple sorted streams using a heap-based tournament, and leverage XOR's self-inverse property to find missing or unique elements in O(1) space.

Introduction to K-Way Merge
Merge K Sorted Lists
Kth Smallest in M Sorted Lists & Sorted Matrix
Introduction to Bitwise XOR Tricks
Single Number I, II & Missing/Corrupt Number
Flip and Complement & Counting Bits
Checkpoint: K-Way Merge & XOR Drill
10

Graph Traversal & Topological Sort

7 lessons

Represent and traverse graphs with BFS and DFS, detect cycles, and produce topological orderings of directed acyclic graphs using Kahn's algorithm.

Graph Representations & Traversal Foundations
Number of Islands & Flood Fill (Matrix DFS/BFS)
Cycle Detection in Directed & Undirected Graphs
Introduction to Topological Sort (Kahn's Algorithm)
Course Schedule I & II (Task Dependencies)
Alien Dictionary (Hard)
Checkpoint: Graph & Topological Sort Mastery
11

Dynamic Programming Patterns

7 lessons

Recognize overlapping subproblems and optimal substructure across five DP families — 0/1 Knapsack, Unbounded Knapsack, Fibonacci, Palindromic Subsequences, and Longest Common Substring.

DP Fundamentals: Memoization vs. Tabulation
0/1 Knapsack & Equal Subset Sum Partition
Unbounded Knapsack: Coin Change & Rod Cutting
Fibonacci Numbers Pattern: Staircase & House Robber
Longest Common Subsequence & Edit Distance
Longest Palindromic Subsequence & Substring
Checkpoint: DP Pattern Classification & Solve
12

Mock Interviews & Pattern Mastery

6 lessons

Apply all 16 patterns under simulated interview conditions — practice pattern recognition from problem statements, optimize solutions, and communicate your thought process clearly.

Pattern Recognition Decision Framework
Time & Space Complexity Tradeoff Analysis
Mock Interview 1: Arrays & Strings
Mock Interview 2: Trees & Graphs
Mock Interview 3: Dynamic Programming & Mixed Patterns
Blind 75 Pattern Mapping & Gap Analysis