Blind 75

60 articles

Detailed walkthroughs for the canonical Blind 75 problems, focusing on the decision-making that leads to optimal patterns.

Easy

Two Sum — One-Pass Hash Map

Eliminate the quadratic brute force by caching complements as you sweep the array once.

ArrayHash MapComplement Search
Easy

Best Time to Buy and Sell Stock — Track a Running Minimum

Capture the lowest buying price so far and measure profit deltas in a single scan.

ArrayDynamic ProgrammingGreedy
Medium

Longest Substring Without Repeating Characters — Sliding Window Map

Slide a window while remembering the last index of each character so duplicates never stay in view.

Sliding WindowHash MapString
Medium

Longest Palindromic Substring — Expand Around Center

Treat every character and gap as a center, expanding while the ends mirror each other to find the best span.

Two PointersExpand Around CenterString
Medium

Graph Valid Tree — Union Find Cycle Check

Treat the graph as a disjoint set; every edge must connect two different components and the graph needs exactly n − 1 edges.

GraphUnion FindBreadth-First Search
Medium

Palindromic Substrings — Count by Expanding Centers

Expand around every index and gap to count palindromic substrings without building a DP table.

Expand Around CenterStringCounting
Medium

Container With Most Water — Two-Pointer Contraction

Hold both ends of the array and always move the shorter wall inward to maximise trapped area in one pass.

Two PointersArrayGreedy
Medium

Word Break — BFS Over Split Positions

Treat indices as graph nodes and BFS through valid dictionary cuts to decide whether the entire string can be segmented.

Dynamic ProgrammingBreadth-First SearchString
Easy

Linked List Cycle — Floyd’s Tortoise and Hare

Run two pointers at different speeds; if a cycle exists they eventually collide without any extra memory.

Linked ListTwo PointersCycle Detection
Easy

Missing Number — Arithmetic Series Difference

Compute the expected sum of 0..n and subtract the observed sum to recover the missing value in constant space.

MathArray
Medium

3Sum — Sort Then Two-Pointer Search

Sort the array, fix one value, and sweep the remaining window with two pointers while skipping duplicates.

Two PointersSortingArray
Medium

Reorder List — Split, Reverse, Merge

Break the list in half, reverse the back half, and weave the two lists together to match L0, Ln, L1, Ln-1 ... order.

Linked ListTwo Pointers
Hard

Alien Dictionary — Topological Sort on Characters

Compare adjacent words to derive ordering constraints between letters, then perform Kahn’s algorithm.

GraphTopological SortString
Medium

Remove Nth Node From End — One-Pass Two Pointers

Advance a front pointer n steps ahead so that when it hits null, the trailing pointer sits right before the node to remove.

Linked ListTwo Pointers
Easy

Valid Parentheses — Stack-Based Matching

Push opening brackets onto a stack and ensure every closing bracket matches the most recent opener.

StackString
Easy

Merge Two Sorted Lists — Dummy Head Merge

Use a dummy head and advance two pointers, always stitching the smaller node into the merged list.

Linked ListTwo Pointers
Hard

Merge k Sorted Lists — Min-Heap Merge

Push the head of each list into a min-heap and repeatedly extract the smallest node to build the merged list.

HeapLinked ListDivide and Conquer
Medium

Maximum Product Subarray — Track Hi/Lo Products

Maintain both the highest and lowest running product because negative numbers can flip the sign of the result.

Dynamic ProgrammingArray
Medium

Find Minimum in Rotated Sorted Array — Binary Search on Sorted Halves

Use binary search to locate the pivot: if the mid element is greater than the rightmost element, search the right half; otherwise search the left.

Binary SearchArray
Medium

Search in Rotated Sorted Array — Pivot-Aware Binary Search

Decide which side of the pivot is sorted at every step so the binary search converges on the target in logarithmic time.

Binary SearchArray
Medium

Combination Sum — Backtracking with Reuse

Perform depth-first search, deciding how many times to pick each candidate while keeping the combination in non-decreasing order.

BacktrackingDFS
Medium

Rotate Image — Layered Matrix Transpose and Reverse

Transpose the square matrix then reverse each row to achieve an in-place 90° rotation.

MatrixIn-Place
Medium

Group Anagrams — Canonical Signature Hashing

Use a canonical key (sorted string or frequency vector) to bucket anagrams together in linearithmic time overall.

Hash MapString
Medium

Maximum Subarray — Kadane’s Running Sum

Carry a running best prefix; reset when it becomes negative so the subarray that follows starts fresh.

Dynamic ProgrammingArray
Medium

Spiral Matrix — Layer-by-Layer Traversal

Maintain four boundaries (top, bottom, left, right) and peel layers while updating them carefully.

MatrixSimulation
Medium

Jump Game — Greedy Furthest Reach

Track the furthest index reachable so far; if you ever fall behind the current index, the end cannot be reached.

GreedyArray
Medium

Merge Intervals — Sort Then Sweep

Sort intervals by start time and greedily merge overlapping ranges with a running tail pointer.

IntervalSorting
Medium

Insert Interval — Merge While Inserting

Walk the sorted intervals, append those ending before the new interval, merge overlaps, then append the rest.

IntervalGreedy
Easy

Subtree of Another Tree — Serialize or DFS Compare

Either serialise both trees and search for the subtree pattern or perform depth-first node comparisons with early pruning.

TreeDFS
Medium

Unique Paths — Grid Dynamic Programming

Count paths from top-left to bottom-right by summing ways from the top and left neighbors.

Dynamic ProgrammingGrid
Easy

Reverse Bits — Bitwise Swapping

Swap symmetric bit pairs by shifting and masking until you have reversed the 32-bit integer.

Bit Manipulation
Easy

Number of 1 Bits — Brian Kernighan’s Trick

Clear the lowest set bit repeatedly by applying n & (n - 1) until the number becomes zero.

Bit Manipulation
Medium

Coin Change — Bottom-Up Dynamic Programming

Build the minimum coins needed for each amount up to target using previously computed states.

Dynamic Programming
Medium

Number of Connected Components — Union-Find Tracking

Initialise each node in its own set and union edges; the remaining number of roots equals the connected components.

Union FindGraph
Easy

Climbing Stairs — Fibonacci DP

Reuse the recurrence f(n) = f(n-1) + f(n-2) with constant space to count distinct stair-climbing ways.

Dynamic Programming
Medium

House Robber — Linear DP with Two Choices

At each house decide whether to rob it by comparing robbing plus skipping previous versus skipping now.

Dynamic Programming
Medium

Number of Islands — DFS Flood Fill

Treat the grid as a graph; whenever you encounter land, run DFS/BFS to sink the entire island and increment the count.

DFSBFSGrid
Medium

Set Matrix Zeroes — Mark First Row and Column

Use the first row and column as markers to remember which rows and columns should be zeroed without extra space.

Matrix
Hard

Minimum Window Substring — Sliding Window with Counts

Expand the window to satisfy the requirement, then shrink from the left to find the smallest valid window.

Sliding WindowHash Map
Easy

Reverse Linked List — Iterative Pointer Reversal

Walk the list once while rewiring next pointers to build the reversed list in-place.

Linked List
Medium

Word Search — Backtracking on a Grid

Perform DFS from each cell, marking visited cells temporarily to avoid reuse within the same path.

BacktrackingGrid
Medium

Course Schedule — Topological Sort with Cycle Detection

Use Kahn’s algorithm (BFS) or DFS to detect cycles in the prerequisite graph and decide feasibility.

GraphTopological Sort
Medium

Implement Trie — Prefix Tree Operations

Build a node structure with child maps and an isWord flag to support insert, search, and prefix queries in O(L).

TriePrefix Tree
Easy

Counting Bits — DP from Lowest Set Bit

Use the recurrence dp[i] = dp[i >> 1] + (i & 1) to build popcounts from 0 to n.

Dynamic ProgrammingBit Manipulation
Hard

Word Search II — Trie-Guided Backtracking

Insert all words into a trie and prune DFS paths that are not prefixes, collecting matches as you traverse.

TrieBacktrackingGrid
Easy

Contains Duplicate — Hash Set Membership

Track seen numbers in a set; if a value appears twice, return true immediately.

Hash SetArray
Medium

Decode Ways — DP Over Digits

Use dp[i] representing ways to decode the prefix up to i by considering one or two-digit translations.

Dynamic ProgrammingString
Medium

Top K Frequent Elements — Bucket or Heap

Count element frequencies with a hash map and extract the top k using either a min-heap or frequency buckets.

HeapHash Map
Medium

Meeting Rooms II — Sweep Line on Start/End Times

Separate start and end times, sort both, and sweep to find the maximum number of concurrent meetings.

IntervalHeap
Easy

Invert Binary Tree — Recursive Swap

Swap left and right children at every node using recursion or BFS to mirror the tree.

TreeBFS
Easy

Same Tree — Parallel DFS Comparison

Traverse both trees simultaneously; if nodes mismatch in structure or value, return false.

TreeDFS
Medium

Binary Tree Level Order Traversal — BFS by Levels

Use a queue to traverse nodes level by level, collecting values into lists per depth.

TreeBFS
Easy

Maximum Depth of Binary Tree — DFS Height Calculation

Return 1 plus the maximum depth of left and right subtrees using recursion.

TreeDFS
Easy

Lowest Common Ancestor in BST — Guided Descent

Leverage BST ordering: move left or right until the current node splits the two targets.

TreeBinary Search Tree
Medium

Product of Array Except Self — Prefix and Suffix Multiplication

Compute prefix products and suffix products to fill the output without division.

Array
Easy

Valid Anagram — Frequency Comparison

Count character frequencies in both strings and ensure the counts match exactly.

Hash MapString
Medium

Sum of Two Integers — Bitwise Addition

Use XOR for partial sums and AND/shift for carries until no carry remains.

Bit Manipulation
Easy

Meeting Rooms — Sort and Check Overlaps

Sort intervals by start time and ensure each meeting starts after the previous one ends.

IntervalSorting
Hard

Binary Tree Maximum Path Sum — DFS with Returning Branch Gains

Compute the best downward gain from each node while tracking the maximum path that can pass through the node.

TreeDFS
Easy

Valid Palindrome — Two-Pointer Scan Ignoring Non-Alphanumerics

Move pointers inward while skipping non-alphanumeric characters; compare lowercased characters for equality.

Two PointersString