Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 13 — 1-D Dynamic Programming

Dynamic programming is the technique of breaking a problem into overlapping subproblems, solving each once, and storing the result to avoid recomputation. In one-dimensional DP, each state depends only on a fixed number of previous states, so the solution builds a single array from left to right. The first step is always identifying the recurrence: what does the answer at position i depend on? The problems here cover the core DP patterns you will see repeatedly: linear sequences, knapsack decisions, and string segmentation. DP problems are notoriously hard to recognize, and the only reliable way to get better at them is to solve many and study the structure of their recurrences.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 14 — 2-D Dynamic Programming

Two-dimensional DP extends the same ideas to problems where the state depends on two variables simultaneously, typically two indices into two sequences or two dimensions of a grid. The table is now a matrix, and each cell is filled based on cells above it, to its left, or diagonally adjacent. The problems here include string comparison (edit distance, longest common subsequence), grid path counting, and interval DP where you think about ranges rather than prefixes. These problems tend to be harder to set up than 1-D DP, but once you identify the state and the transition, the code follows directly from the recurrence.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 3Sum

Given an array of integers, find all unique triplets that sum to zero. You sort the array first, then for each element use two pointers to find pairs that complete the triplet. The sort plus two pointers bring it from O(n³) to O(n²). This problem teaches you to extend the two pointer technique beyond pairs and introduces how sorting enables smarter traversal. Visit the question on the LeetCode [website](https://leetcode.com/problems/3sum/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 12 — Advanced Graphs

Advanced graph problems involve weighted edges, which require more sophisticated algorithms than simple BFS or DFS. Dijkstra's algorithm finds the shortest path in a weighted graph using a min-heap. Prim's and Kruskal's algorithms find the minimum spanning tree, connecting all nodes at minimum total cost. These algorithms are more complex than anything seen so far, and the problems here often combine the algorithm with an additional constraint, such as a limit on the number of steps or a non-standard cost function. Understanding the conditions under which each algorithm applies is as important as knowing how to implement it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 1 — Arrays & Hashing

Arrays and hash maps are the building blocks of almost every algorithm problem. Before learning any pattern, you need to be comfortable navigating an array and reaching for a hash map when you need fast lookups. Most problems in this stage are solved in one or two passes, and the main skill you are developing is recognizing when a hash map can replace a nested loop. If you find yourself thinking about checking membership or counting frequencies, a hash map is almost always the right tool.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 9 — Backtracking

Backtracking is a systematic way to explore all possible solutions by making a choice, recursing, and undoing the choice when you backtrack. It is the right tool for problems that ask for all combinations, all permutations, all subsets, or any valid configuration. The key skill is recognizing when to prune: stopping a branch early when you can tell it cannot lead to a valid solution. Without pruning, backtracking is just brute force. Most problems here share the same recursive skeleton and differ only in the constraints that determine valid choices and stopping conditions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Best Time to Buy and Sell Stock

Given an array of daily stock prices, find the maximum profit from one buy and one sell. You track the minimum price seen so far and the best profit achievable at each step using a single pass. This is the simplest sliding window problem since the window always expands from the current day, and it teaches you how to track a running minimum and maximum simultaneously. Visit the question on the LeetCode [website](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 4 — Binary Search

Binary search is not just for finding an element in a sorted array. It is a general technique for eliminating half the search space at each step, and it applies whenever you can define a condition that splits possible answers into a valid half and an invalid half. The problems in this stage move from the textbook version to more creative applications: searching in rotated arrays, and binary searching on the answer itself rather than on the input. Getting binary search right under pressure, with correct boundary conditions, is a skill that requires deliberate practice.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Binary Search

Given a sorted array and a target, return the index of the target or -1 if not found. You repeatedly halve the search space by comparing the middle element to the target. This is the simplest form of binary search and the one you must be able to write without mistakes before moving to harder variants. Visit the question on the LeetCode [website](https://leetcode.com/problems/binary-search/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Binary Tree Level Order Traversal

Given a binary tree, return its node values level by level. You use a queue to process all nodes at one level before moving to the next, collecting each level into its own list. This is the entry point for tree BFS and teaches you the queue-based level tracking pattern that applies to many tree and graph problems. Visit the question on the LeetCode [website](https://leetcode.com/problems/binary-tree-level-order-traversal/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Binary Tree Maximum Path Sum

Given a binary tree where nodes can have negative values, find the maximum sum of any path between any two nodes. At each node you decide whether to extend either child's path or start fresh, tracking the global maximum as you go. This is one of the hardest tree DFS problems and teaches you to separate what you return up the recursion from what you record as your answer. Visit the question on the LeetCode [website](https://leetcode.com/problems/binary-tree-maximum-path-sum/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 17 — Bit Manipulation

Bit manipulation uses the binary representation of integers directly through bitwise operators: AND, OR, XOR, and shifts. It is useful for problems involving pairs, uniqueness, flags, or any situation where you need to extract or toggle individual bits. XOR is particularly powerful because it is its own inverse: XOR-ing a value twice cancels out. The problems here are mostly short, but they require a different way of thinking about numbers. Once you internalize the basic bit operations, you will start seeing where they can replace more expensive data structures in problems across other categories.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Burst Balloons

Given an array of balloons with values, burst all of them to maximize coins, where bursting a balloon gives coins equal to the product of itself and its neighbors. You use interval DP: instead of choosing which balloon to burst first, you choose which to burst last within each interval. This problem teaches you that sometimes reversing the order of decisions makes the DP structure cleaner. Visit the question on the LeetCode [website](https://leetcode.com/problems/burst-balloons/).
3 changes: 3 additions & 0 deletions src/data/roadmaps/leetcode/content/c@IWmq4UFB5j6O3UJfarh1u.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# C++

C++ is the language of choice for competitive programmers and is common in companies where raw performance matters, such as systems, gaming, or high-frequency trading. It has the fastest execution time of any commonly used interview language and gives you direct access to the standard template library, which includes a heap, set, map, and many other useful structures. The tradeoff is verbosity and the overhead of managing memory manually in some cases. If you are already proficient in C++, it is an excellent interview language. If you are starting from scratch, the learning curve is steep.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Longest Repeating Character Replacement

Given a string and a number k, find the length of the longest substring where you can replace at most k characters to make all characters the same. You track the count of the most frequent character in the window, and if the window size minus that count exceeds k, you shrink from the left. This problem teaches you a clever invariant: you never need to shrink the window below its maximum size seen so far. Visit the question on the LeetCode [website](https://leetcode.com/problems/longest-repeating-character-replacement/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Cheapest Flights Within K Stops

Given a graph of flights with prices, find the cheapest route from source to destination using at most k stops. This is a modified Dijkstra or Bellman-Ford problem where the constraint is on the number of edges, not just total cost. This problem teaches you how to add an extra dimension (number of steps) to a shortest path algorithm. Visit the question on the LeetCode [website](https://leetcode.com/problems/cheapest-flights-within-k-stops/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Climbing Stairs

You can climb one or two steps at a time. Find the number of distinct ways to reach the top of n stairs. The number of ways to reach step n is the sum of ways to reach n-1 and n-2, which is exactly the Fibonacci pattern. This is the entry point to DP and teaches you to see a problem as a recurrence: the answer at each state depends on previous states. Visit the question on the LeetCode [website](https://leetcode.com/problems/climbing-stairs/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Clone Graph

Given a connected undirected graph, return a deep copy of it. You use DFS or BFS and a hash map to track which nodes have already been cloned, so you do not create duplicate copies when revisiting nodes. This problem teaches you to handle graphs with cycles during traversal, which requires tracking visited nodes from the start. Visit the question on the LeetCode [website](https://leetcode.com/problems/clone-graph/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Coin Change

Given coin denominations and a target amount, find the minimum number of coins needed. You build a DP table where each amount stores the fewest coins to make it, using each coin to update future amounts. This is the canonical unbounded knapsack problem and teaches you bottom-up DP where you iterate over amounts rather than items. Visit the question on the LeetCode [website](https://leetcode.com/problems/coin-change/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Combination Sum

Given an array of distinct integers and a target, return all unique combinations that sum to the target, where each number can be used unlimited times. You use backtracking, and at each step either reuse the current number or move to the next. This problem teaches you how to allow repetition in backtracking by staying at the same index instead of advancing. Visit the question on the LeetCode [website](https://leetcode.com/problems/combination-sum/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Container With Most Water

Given an array of bar heights, find two bars that together with the x-axis form a container holding the most water. You start with the widest possible container and move the pointer on the shorter side inward, since that is the only move that could increase the area. This problem teaches the key insight that moving the longer side never helps, which is a non-obvious greedy choice that the two pointer pattern makes visible. Visit the question on the LeetCode [website](https://leetcode.com/problems/container-with-most-water/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contains Duplicate

Given an array, return true if any value appears more than once. The brute force compares every pair, but a hash set lets you check for duplicates in a single pass. Simple as it sounds, this problem is your first introduction to using a set for O(1) membership checks, a pattern you will see in almost every stage. Visit the question on the LeetCode [website](https://leetcode.com/problems/contains-duplicate/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Counting Bits

Given an integer n, return an array where each element is the number of 1 bits in its binary representation from 0 to n. You can use DP: the number of bits in i equals one plus the bits in i with its lowest set bit removed. This problem teaches you to combine bit manipulation with DP to avoid recomputing from scratch for each number. Visit the question on the LeetCode [website](https://leetcode.com/problems/counting-bits/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Course Schedule

Given a list of courses and prerequisites, determine if it is possible to finish all courses. This is a cycle detection problem in a directed graph: if any cycle exists, the schedule is impossible. You can solve it with DFS by tracking nodes in the current recursion path. This problem teaches you topological sort thinking and is a gateway to all dependency-based graph problems. Visit the question on the LeetCode [website](https://leetcode.com/problems/course-schedule/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Daily Temperatures

Given an array of daily temperatures, return an array where each element is the number of days until a warmer temperature. A monotonic stack stores indices of temperatures in decreasing order, and whenever a warmer day is found, all colder days in the stack get their answer. This problem is the entry point for the monotonic stack pattern, which appears in many harder problems. Visit the question on the LeetCode [website](https://leetcode.com/problems/daily-temperatures/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Design Add and Search Words Data Structure

Build a data structure that supports adding words and searching for words where a dot can match any letter. Exact characters navigate the trie normally, while a dot triggers DFS across all child nodes. This problem teaches you how to combine trie traversal with backtracking for wildcard matching. Visit the question on the LeetCode [website](https://leetcode.com/problems/design-add-and-search-words-data-structure/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Edit Distance

Given two strings, find the minimum number of insertions, deletions, or replacements to transform one into the other. A 2D DP table tracks the cost to convert each prefix of one string to each prefix of the other. This problem teaches you the three-way choice at each cell (insert, delete, replace) and is a foundational example of DP on two sequences. Visit the question on the LeetCode [website](https://leetcode.com/problems/edit-distance/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Find Median from Data Stream

Design a data structure that supports adding numbers one by one and returning the median at any point. You maintain two heaps: a max-heap for the lower half and a min-heap for the upper half, keeping them balanced so the median is always accessible at the top. This is the defining two-heap problem and teaches you how splitting a dataset into two heaps gives O(log n) insertion and O(1) median retrieval. Visit the question on the LeetCode [website](https://leetcode.com/problems/find-median-from-data-stream/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Gas Station

Given gas amounts and costs at each station on a circular route, find the starting station from which you can complete the circuit. If total gas is at least total cost, a solution exists, and the starting point is always after the last segment where the running tank went negative. This problem teaches you that a global observation (total gas vs total cost) can determine existence, while a local scan finds the answer. Visit the question on the LeetCode [website](https://leetcode.com/problems/gas-station/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generate Parentheses

Given n, generate all combinations of well-formed parentheses. You build strings recursively, adding an opening bracket if you still have some left and a closing bracket only if it would not break validity. This problem sits at the boundary of stack and backtracking thinking, and teaches you to use constraints to prune a search space before exploring it. Visit the question on the LeetCode [website](https://leetcode.com/problems/generate-parentheses/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Go

Go is a statically typed, compiled language designed for simplicity and performance. It is increasingly popular in backend and infrastructure roles and is commonly used at companies like Uber, Cloudflare, and Docker. Its syntax is minimal and its concurrency model is distinctive, but for LeetCode purposes what matters is its straightforward standard library and fast execution. Go does not have a built-in generic data structure library as rich as Java or C++, so you will sometimes need to implement things like heaps from scratch using the container/heap interface. It is a good choice if Go is your day-to-day language.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 11 — Graphs

Graphs generalize trees by allowing arbitrary connections and cycles. The two core traversal techniques, DFS and BFS, work on graphs the same way they do on trees, but you must now track visited nodes explicitly to avoid infinite loops. This stage covers the main graph problem types: counting connected components, detecting cycles, finding shortest paths in unweighted graphs, and topological ordering of dependencies. Grids are also implicit graphs, where each cell is a node and adjacency is defined by its four neighbors. Most graph problems reduce to one of these patterns once you recognize the structure.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stage 15 — Greedy

Greedy algorithms make the locally optimal choice at each step and never revisit decisions. They are faster and simpler than DP when they work, but proving that a greedy choice leads to a globally optimal solution is not always obvious. The problems in this stage cover the most common greedy patterns: interval scheduling, jump games, and character frequency problems. A useful habit is to first ask whether a greedy approach is correct before coding it: can a short-sighted choice ever lead you away from the best solution? If the answer is yes, you probably need DP instead.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Group Anagrams

Given a list of strings, group together all strings that are anagrams of each other. Since anagrams share the same characters, sorting each string gives a common key you can use in a hash map. A more optimal approach uses character frequency arrays as keys instead of sorting. This problem teaches you to think about what makes two things equivalent and use that equivalence as a grouping key, a useful mental model for many hash map problems. Visit the question on the LeetCode [website](https://leetcode.com/problems/group-anagrams/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Happy Number

A happy number is one that eventually reaches 1 when you repeatedly replace it with the sum of the squares of its digits. Detect whether a number is happy. This is a cycle detection problem: if the process loops without reaching 1, the number is not happy. You can use Floyd's algorithm or a set to detect the cycle. This problem teaches you to recognize cycle detection in non-graph contexts. Visit the question on the LeetCode [website](https://leetcode.com/problems/happy-number/).
Loading