Skip to content
We areTOP 1%
DSA · 10 patterns · 147 questions

Intermediate DSA

For students comfortable with the basics who are preparing for interviews and early contests. Covers sliding windows, binary search on the answer, monotonic stacks, binary trees, heaps, backtracking, greedy algorithms, graph traversal and 1-D dynamic programming, with Codeforces problems rated 1100–1500.
Intermediate progress0%
1st Visit
0/147
2nd Visit
0/147
Revise
0/147

Sliding Window

0/14

A sliding window maintains a contiguous range [l, r] and updates a summary of it (a sum, a frequency table, a count of distinct items) incrementally as the right end…

Pattern guide
Sliding Window questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Maximum Average Subarray ILeetCodeEasy Solve Maximum Average Subarray I on LeetCode (opens in a new tab)
2Lecture SleepCodeforcesEasy 1200Solve Lecture Sleep on Codeforces (opens in a new tab)
3Ternary StringCodeforcesEasy 1200Solve Ternary String on Codeforces (opens in a new tab)
4Binary DequeCodeforcesEasy 1200Solve Binary Deque on Codeforces (opens in a new tab)
5Longest Substring Without Repeating CharactersLeetCodeMedium Solve Longest Substring Without Repeating Characters on LeetCode (opens in a new tab)
6Permutation in StringLeetCodeMedium Solve Permutation in String on LeetCode (opens in a new tab)
7Max Consecutive Ones IIILeetCodeMedium Solve Max Consecutive Ones III on LeetCode (opens in a new tab)
8Fruit Into BasketsLeetCodeMedium Solve Fruit Into Baskets on LeetCode (opens in a new tab)
9Longest Repeating Character ReplacementLeetCodeMedium Solve Longest Repeating Character Replacement on LeetCode (opens in a new tab)
10Money TreesCodeforcesMedium 1300Solve Money Trees on Codeforces (opens in a new tab)
11BooksCodeforcesMedium 1400Solve Books on Codeforces (opens in a new tab)
12Vasya and StringCodeforcesMedium 1500Solve Vasya and String on Codeforces (opens in a new tab)
13Minimum Window SubstringLeetCodeHard Solve Minimum Window Substring on LeetCode (opens in a new tab)
14Sliding Window MaximumLeetCodeHard Solve Sliding Window Maximum on LeetCode (opens in a new tab)

Binary Search on Answer

0/13

When the answer is a number and you can cheaply check whether a candidate value is feasible, binary search over the answer instead of over an array. The key is…

Pattern guide
Binary Search on Answer questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Building an AquariumCodeforcesEasy 1100Solve Building an Aquarium on Codeforces (opens in a new tab)
2Poisoned DaggerCodeforcesEasy 1200Solve Poisoned Dagger on Codeforces (opens in a new tab)
3Koko Eating BananasLeetCodeMedium Solve Koko Eating Bananas on LeetCode (opens in a new tab)
4Find the Smallest Divisor Given a ThresholdLeetCodeMedium Solve Find the Smallest Divisor Given a Threshold on LeetCode (opens in a new tab)
5Capacity To Ship Packages Within D DaysLeetCodeMedium Solve Capacity To Ship Packages Within D Days on LeetCode (opens in a new tab)
6Minimum Number of Days to Make m BouquetsLeetCodeMedium Solve Minimum Number of Days to Make m Bouquets on LeetCode (opens in a new tab)
7Magnetic Force Between Two BallsLeetCodeMedium Solve Magnetic Force Between Two Balls on LeetCode (opens in a new tab)
8Chat BanCodeforcesMedium 1300Solve Chat Ban on Codeforces (opens in a new tab)
9Magic Powder - 1CodeforcesMedium 1400Solve Magic Powder - 1 on Codeforces (opens in a new tab)
10Maximum MedianCodeforcesMedium 1400Solve Maximum Median on Codeforces (opens in a new tab)
11Jumping Through SegmentsCodeforcesMedium 1400Solve Jumping Through Segments on Codeforces (opens in a new tab)
12Split Array Largest SumLeetCodeHard Solve Split Array Largest Sum on LeetCode (opens in a new tab)
13Kth Smallest Number in Multiplication TableLeetCodeHard Solve Kth Smallest Number in Multiplication Table on LeetCode (opens in a new tab)

Monotonic Stack

0/12

A monotonic stack keeps its elements in increasing or decreasing order; before pushing a new element, it pops every element the newcomer makes irrelevant. At the moment…

Pattern guide
Monotonic Stack questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Next Greater Element ILeetCodeEasy Solve Next Greater Element I on LeetCode (opens in a new tab)
2Bad PricesCodeforcesEasy 1100Solve Bad Prices on Codeforces (opens in a new tab)
3Minimum NotationCodeforcesEasy 1200Solve Minimum Notation on Codeforces (opens in a new tab)
4Next Greater Element IILeetCodeMedium Solve Next Greater Element II on LeetCode (opens in a new tab)
5Daily TemperaturesLeetCodeMedium Solve Daily Temperatures on LeetCode (opens in a new tab)
6Online Stock SpanLeetCodeMedium Solve Online Stock Span on LeetCode (opens in a new tab)
7Remove K DigitsLeetCodeMedium Solve Remove K Digits on LeetCode (opens in a new tab)
8Largest SubsequenceCodeforcesMedium 1400Solve Largest Subsequence on Codeforces (opens in a new tab)
9Sum of Subarray MinimumsLeetCodeMedium Solve Sum of Subarray Minimums on LeetCode (opens in a new tab)
10Skyscrapers (easy version)CodeforcesMedium 1500Solve Skyscrapers (easy version) on Codeforces (opens in a new tab)
11Largest Rectangle in HistogramLeetCodeHard Solve Largest Rectangle in Histogram on LeetCode (opens in a new tab)
12Maximal RectangleLeetCodeHard Solve Maximal Rectangle on LeetCode (opens in a new tab)

Binary Trees

0/20

Binary tree problems are recursive by nature: every node has a left and a right subtree, and most answers combine results from the two subtrees with the value at the…

Pattern guide
Binary Trees questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Binary Tree Inorder TraversalLeetCodeEasy Solve Binary Tree Inorder Traversal on LeetCode (opens in a new tab)
2Maximum Depth of Binary TreeLeetCodeEasy Solve Maximum Depth of Binary Tree on LeetCode (opens in a new tab)
3Invert Binary TreeLeetCodeEasy Solve Invert Binary Tree on LeetCode (opens in a new tab)
4Symmetric TreeLeetCodeEasy Solve Symmetric Tree on LeetCode (opens in a new tab)
5Balanced Binary TreeLeetCodeEasy Solve Balanced Binary Tree on LeetCode (opens in a new tab)
6Diameter of Binary TreeLeetCodeEasy Solve Diameter of Binary Tree on LeetCode (opens in a new tab)
7Permutation TransformationCodeforcesEasy 1200Solve Permutation Transformation on Codeforces (opens in a new tab)
8Apple TreeCodeforcesEasy 1200Solve Apple Tree on Codeforces (opens in a new tab)
9Binary Tree Level Order TraversalLeetCodeMedium Solve Binary Tree Level Order Traversal on LeetCode (opens in a new tab)
10Binary Tree Zigzag Level Order TraversalLeetCodeMedium Solve Binary Tree Zigzag Level Order Traversal on LeetCode (opens in a new tab)
11Count Good Nodes in Binary TreeLeetCodeMedium Solve Count Good Nodes in Binary Tree on LeetCode (opens in a new tab)
12Path Sum IILeetCodeMedium Solve Path Sum II on LeetCode (opens in a new tab)
13Anji's Binary TreeCodeforcesMedium 1300Solve Anji's Binary Tree on Codeforces (opens in a new tab)
14Masha and a Beautiful TreeCodeforcesMedium 1300Solve Masha and a Beautiful Tree on Codeforces (opens in a new tab)
15Construct Binary Tree from Preorder and Inorder TraversalLeetCodeMedium Solve Construct Binary Tree from Preorder and Inorder Traversal on LeetCode (opens in a new tab)
16Flatten Binary Tree to Linked ListLeetCodeMedium Solve Flatten Binary Tree to Linked List on LeetCode (opens in a new tab)
17Maximum Width of Binary TreeLeetCodeMedium Solve Maximum Width of Binary Tree on LeetCode (opens in a new tab)
18All Nodes Distance K in Binary TreeLeetCodeMedium Solve All Nodes Distance K in Binary Tree on LeetCode (opens in a new tab)
19Cut 'em all!CodeforcesMedium 1500Solve Cut 'em all! on Codeforces (opens in a new tab)
20Vertical Order Traversal of a Binary TreeLeetCodeHard Solve Vertical Order Traversal of a Binary Tree on LeetCode (opens in a new tab)

Heap / Priority Queue

0/13

A binary heap, available in C++ as priority queue, returns the largest (or smallest) element in O(1) and supports insertion and removal in O(log n). Use it when you…

Pattern guide
Heap / Priority Queue questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Last Stone WeightLeetCodeEasy Solve Last Stone Weight on LeetCode (opens in a new tab)
2Kth Largest Element in a StreamLeetCodeEasy Solve Kth Largest Element in a Stream on LeetCode (opens in a new tab)
3Powering the Hero (hard version)CodeforcesEasy 1100Solve Powering the Hero (hard version) on Codeforces (opens in a new tab)
4Kth Largest Element in an ArrayLeetCodeMedium Solve Kth Largest Element in an Array on LeetCode (opens in a new tab)
5K Closest Points to OriginLeetCodeMedium Solve K Closest Points to Origin on LeetCode (opens in a new tab)
6Task SchedulerLeetCodeMedium Solve Task Scheduler on LeetCode (opens in a new tab)
7Phoenix and TowersCodeforcesMedium 1400Solve Phoenix and Towers on Codeforces (opens in a new tab)
8Productive MeetingCodeforcesMedium 1400Solve Productive Meeting on Codeforces (opens in a new tab)
9Digital LogarithmCodeforcesMedium 1400Solve Digital Logarithm on Codeforces (opens in a new tab)
10Potions (Easy Version)CodeforcesMedium 1500Solve Potions (Easy Version) on Codeforces (opens in a new tab)
11Lunar New Year and a WanderCodeforcesMedium 1500Solve Lunar New Year and a Wander on Codeforces (opens in a new tab)
12Merge k Sorted ListsLeetCodeHard Solve Merge k Sorted Lists on LeetCode (opens in a new tab)
13Find Median from Data StreamLeetCodeHard Solve Find Median from Data Stream on LeetCode (opens in a new tab)

Backtracking

0/14

Backtracking builds candidate solutions one choice at a time and abandons a partial candidate as soon as it cannot lead to a valid answer. It is a depth first search…

Pattern guide
Backtracking questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1PenaltyCodeforcesEasy 1200Solve Penalty on Codeforces (opens in a new tab)
2SubsetsLeetCodeMedium Solve Subsets on LeetCode (opens in a new tab)
3PermutationsLeetCodeMedium Solve Permutations on LeetCode (opens in a new tab)
4Subsets IILeetCodeMedium Solve Subsets II on LeetCode (opens in a new tab)
5Combination SumLeetCodeMedium Solve Combination Sum on LeetCode (opens in a new tab)
6Combination Sum IILeetCodeMedium Solve Combination Sum II on LeetCode (opens in a new tab)
7Dreamoon and WiFiCodeforcesMedium 1300Solve Dreamoon and WiFi on Codeforces (opens in a new tab)
8Lucky Numbers (easy)CodeforcesMedium 1300Solve Lucky Numbers (easy) on Codeforces (opens in a new tab)
9Palindrome PartitioningLeetCodeMedium Solve Palindrome Partitioning on LeetCode (opens in a new tab)
10Berland CrosswordCodeforcesMedium 1400Solve Berland Crossword on Codeforces (opens in a new tab)
11Preparing OlympiadCodeforcesMedium 1400Solve Preparing Olympiad on Codeforces (opens in a new tab)
12a-Good StringCodeforcesMedium 1500Solve a-Good String on Codeforces (opens in a new tab)
13N-QueensLeetCodeHard Solve N-Queens on LeetCode (opens in a new tab)
14Sudoku SolverLeetCodeHard Solve Sudoku Solver on LeetCode (opens in a new tab)

Greedy

0/17

A greedy algorithm makes the locally best choice at each step and never revisits it. It is correct only when an exchange argument holds: any optimal solution can be…

Pattern guide
Greedy questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Assign CookiesLeetCodeEasy Solve Assign Cookies on LeetCode (opens in a new tab)
2Lemonade ChangeLeetCodeEasy Solve Lemonade Change on LeetCode (opens in a new tab)
3BerSU BallCodeforcesEasy 1200Solve BerSU Ball on Codeforces (opens in a new tab)
4Alternating SubsequenceCodeforcesEasy 1200Solve Alternating Subsequence on Codeforces (opens in a new tab)
5Stable GroupsCodeforcesEasy 1200Solve Stable Groups on Codeforces (opens in a new tab)
6Young ExplorersCodeforcesEasy 1200Solve Young Explorers on Codeforces (opens in a new tab)
7Jump GameLeetCodeMedium Solve Jump Game on LeetCode (opens in a new tab)
8Jump Game IILeetCodeMedium Solve Jump Game II on LeetCode (opens in a new tab)
9Gas StationLeetCodeMedium Solve Gas Station on LeetCode (opens in a new tab)
10Partition LabelsLeetCodeMedium Solve Partition Labels on LeetCode (opens in a new tab)
11Social DistanceCodeforcesMedium 1300Solve Social Distance on Codeforces (opens in a new tab)
12QueueCodeforcesMedium 1300Solve Queue on Codeforces (opens in a new tab)
13ExamsCodeforcesMedium 1400Solve Exams on Codeforces (opens in a new tab)
14Given Length and Sum of Digits...CodeforcesMedium 1400Solve Given Length and Sum of Digits... on Codeforces (opens in a new tab)
15Arranging The SheepCodeforcesMedium 1400Solve Arranging The Sheep on Codeforces (opens in a new tab)
16WoodcuttersCodeforcesMedium 1500Solve Woodcutters on Codeforces (opens in a new tab)
17CandyLeetCodeHard Solve Candy on LeetCode (opens in a new tab)

Graphs: BFS & DFS

0/17

A graph is a set of nodes joined by edges; grids, state spaces and number transformations are often graphs in disguise. Depth first search explores as far as possible…

Pattern guide
Graphs: BFS & DFS questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Flood FillLeetCodeEasy Solve Flood Fill on LeetCode (opens in a new tab)
2The LakesCodeforcesEasy 1100Solve The Lakes on Codeforces (opens in a new tab)
3Ice SkatingCodeforcesEasy 1200Solve Ice Skating on Codeforces (opens in a new tab)
4Number of IslandsLeetCodeMedium Solve Number of Islands on LeetCode (opens in a new tab)
5Rotting OrangesLeetCodeMedium Solve Rotting Oranges on LeetCode (opens in a new tab)
601 MatrixLeetCodeMedium Solve 01 Matrix on LeetCode (opens in a new tab)
7Surrounded RegionsLeetCodeMedium Solve Surrounded Regions on LeetCode (opens in a new tab)
8Clone GraphLeetCodeMedium Solve Clone Graph on LeetCode (opens in a new tab)
9Is Graph Bipartite?LeetCodeMedium Solve Is Graph Bipartite? on LeetCode (opens in a new tab)
10RumorCodeforcesMedium 1300Solve Rumor on Codeforces (opens in a new tab)
11Mahmoud and Ehab and the bipartitenessCodeforcesMedium 1300Solve Mahmoud and Ehab and the bipartiteness on Codeforces (opens in a new tab)
12Arrow PathCodeforcesMedium 1300Solve Arrow Path on Codeforces (opens in a new tab)
13Two ButtonsCodeforcesMedium 1400Solve Two Buttons on Codeforces (opens in a new tab)
14Pacific Atlantic Water FlowLeetCodeMedium Solve Pacific Atlantic Water Flow on LeetCode (opens in a new tab)
15Kefa and ParkCodeforcesMedium 1500Solve Kefa and Park on Codeforces (opens in a new tab)
16Fox And Two DotsCodeforcesMedium 1500Solve Fox And Two Dots on Codeforces (opens in a new tab)
17Word LadderLeetCodeHard Solve Word Ladder on LeetCode (opens in a new tab)

1-D Dynamic Programming

0/15

Dynamic programming solves a problem by combining answers to overlapping subproblems, computing each one only once. In 1 D DP the state is a single index or value…

Pattern guide
1-D Dynamic Programming questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Climbing StairsLeetCodeEasy Solve Climbing Stairs on LeetCode (opens in a new tab)
2Min Cost Climbing StairsLeetCodeEasy Solve Min Cost Climbing Stairs on LeetCode (opens in a new tab)
3Long JumpsCodeforcesEasy 1100Solve Long Jumps on Codeforces (opens in a new tab)
4House RobberLeetCodeMedium Solve House Robber on LeetCode (opens in a new tab)
5House Robber IILeetCodeMedium Solve House Robber II on LeetCode (opens in a new tab)
6Decode WaysLeetCodeMedium Solve Decode Ways on LeetCode (opens in a new tab)
7Coin ChangeLeetCodeMedium Solve Coin Change on LeetCode (opens in a new tab)
8Word BreakLeetCodeMedium Solve Word Break on LeetCode (opens in a new tab)
9Longest Increasing SubsequenceLeetCodeMedium Solve Longest Increasing Subsequence on LeetCode (opens in a new tab)
10Cut RibbonCodeforcesMedium 1300Solve Cut Ribbon on Codeforces (opens in a new tab)
11Just Eat It!CodeforcesMedium 1300Solve Just Eat It! on Codeforces (opens in a new tab)
12Orac and ModelsCodeforcesMedium 1400Solve Orac and Models on Codeforces (opens in a new tab)
13BoredomCodeforcesMedium 1500Solve Boredom on Codeforces (opens in a new tab)
14Mortal Kombat TowerCodeforcesMedium 1500Solve Mortal Kombat Tower on Codeforces (opens in a new tab)
15Block SequenceCodeforcesMedium 1500Solve Block Sequence on Codeforces (opens in a new tab)

Mixed Practice

All patterns0/12

This set closes the Intermediate level with twelve problems drawn from its patterns, including sliding windows, binary search on the answer, monotonic stacks, binary…

Pattern guide
Mixed Practice questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1White-Black Balanced SubtreesCodeforcesMedium 1300Solve White-Black Balanced Subtrees on Codeforces (opens in a new tab)
2Binary Tree Right Side ViewLeetCodeMedium Solve Binary Tree Right Side View on LeetCode (opens in a new tab)
3Hand of StraightsLeetCodeMedium Solve Hand of Straights on LeetCode (opens in a new tab)
4Word SearchLeetCodeMedium Solve Word Search on LeetCode (opens in a new tab)
5Path Sum IIILeetCodeMedium Solve Path Sum III on LeetCode (opens in a new tab)
6VacationsCodeforcesMedium 1400Solve Vacations on Codeforces (opens in a new tab)
7RationalLeeCodeforcesMedium 1400Solve RationalLee on Codeforces (opens in a new tab)
8Inaccurate Subsequence SearchCodeforcesMedium 1400Solve Inaccurate Subsequence Search on Codeforces (opens in a new tab)
9Schedule ManagementCodeforcesMedium 1400Solve Schedule Management on Codeforces (opens in a new tab)
10Epic TransformationCodeforcesMedium 1400Solve Epic Transformation on Codeforces (opens in a new tab)
11Cyclic ComponentsCodeforcesMedium 1500Solve Cyclic Components on Codeforces (opens in a new tab)
12Trapping Rain WaterLeetCodeHard Solve Trapping Rain Water on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account