Push your limits with hand-crafted algorithmic challenges. Solve problems across Trees, Graphs, Dynamic Programming, and more โ with interactive code editors and real test cases.
Solve the problem within 30 minutes to earn points and rank up.
Solve this challenging problem within 30 minutes to earn even more points!
Solve this challenging problem within 60 minutes to earn even more points!
Return all three traversals of a binary tree. Great entry point into recursive tree thinking.
Find the length of the longest root-to-leaf path using elegant recursion.
Count all nodes with no children โ a clean exercise in base-case thinking.
Compute the sum of every node value in the binary tree recursively.
Traverse a binary tree level by level using BFS โ a classic queue-based challenge.
Find the deepest node that is a common ancestor of two given nodes.
Verify that a binary tree satisfies all BST properties using bounds propagation.
Find the longest path (in edges) between any two nodes in the tree.
Return the first and last visible node at every level of the tree.
Design an encode/decode scheme so any tree can be stored and fully reconstructed.
Group tree nodes by column position, breaking ties by row then value.
Rebuild a unique binary tree given its preorder and inorder traversals.
Find the highest-sum path between any two nodes โ negative values make it tricky.
Two BST nodes were swapped by mistake. Restore the tree in O(n) time.
Calculate the n-th Fibonacci number using dynamic programming โ the classic introduction to memoization and tabulation.
Count the distinct ways to climb n stairs taking 1 or 2 steps at a time โ identical recurrence to Fibonacci.
Find the minimum cost to reach the top of a staircase given a cost array โ classic DP optimization.
Maximize loot from non-adjacent houses โ a foundational DP problem with a beautiful two-variable space optimization.
Find the fewest coins to reach a target amount โ introducing unbounded knapsack DP.
Find the length of the longest strictly increasing subsequence โ a cornerstone of sequence DP.
Return the length of the longest common subsequence of two strings โ the canonical 2D DP problem.
Pack a knapsack to maximize value without exceeding capacity โ the quintessential DP on items.
Determine if an array can be split into two subsets with equal sum โ a knapsack variant with a twist.
Count the number of ways to decode a digit string to letters โ blending DP with string parsing.
Count distinct paths from top-left to bottom-right of a grid โ the quintessential 2D DP grid problem.
Find the minimum edit operations (insert, delete, replace) to convert one string to another โ classic interval DP.
Count the number of combinations that sum to a target amount โ unbounded knapsack counting variant.
Find the optimal parenthesization of matrix products to minimize scalar multiplications โ interval DP at its finest.
Find the longest subsequence of a string that is a palindrome โ interval DP on a single string.
Maximize coins by strategically bursting balloons โ a tricky interval DP problem of choosing the last element.
Maximize revenue by cutting a rod into pieces of varying lengths โ unbounded knapsack meets optimization.
Find the minimum number of trials to identify the critical floor โ a deceptively hard DP problem with a clever reformulation.
Rob houses arranged as a binary tree without triggering alarms โ applying DP to tree structures with post-order DFS.
Solve the Travelling Salesman Problem using bitmask DP โ representing visited city sets as integers for exponential state compression.
Merge two sorted arrays into one sorted array in-place.
Find the kth largest element without fully sorting the array.
Merge multiple sorted chunks simulating external disk sorting.
Merge multiple sorted linked lists (simulated as arrays).
Sort a string based on the frequency of its characters.
Find the median of two sorted arrays in logarithmic time.
Build both the adjacency list and adjacency matrix from a list of edges โ the foundation of every graph algorithm.
Traverse a graph as deep as possible along each branch before backtracking โ the backbone of cycle detection and path-finding.
Traverse a graph level by level using a queue โ the foundation for shortest paths in unweighted graphs.
Count how many separate connected components exist in an undirected graph using DFS or Union-Find.
Determine whether a path exists between two vertices and reconstruct it using BFS parent tracking.
Use DFS with parent-tracking to determine if an undirected graph contains a cycle.
Use three-color DFS state tracking to detect back edges and cycles in a directed graph.
Order the vertices of a DAG so every directed edge points forward โ essential for task scheduling problems.
Determine whether a graph's vertices can be 2-colored with no same-color adjacent edges using BFS.
Compute shortest hop-count distances from a source using BFS on an unweighted graph.
Find shortest paths from a source in a weighted graph with non-negative weights using a greedy priority queue.
Compute shortest paths even with negative edge weights, and detect negative-weight cycles in O(VE).
Compute shortest paths between every pair of vertices in O(Vยณ) using all-pairs DP.
Find the minimum-weight edge subset connecting all vertices using Kruskal's sort + Union-Find approach.
Find all maximal sets of mutually reachable vertices in a directed graph using Kosaraju's two-pass DFS.
Maximize the number of content children by greedily assigning the smallest sufficient cookie to each child.
Select the maximum number of non-overlapping meetings that can fit in a single room.
Determine if you can give correct change to every customer at a lemonade stand using a greedy cash-tracking approach.
Check if n flowers can be planted in a flowerbed without any two flowers being adjacent.
Find all pairs of elements with the minimum absolute difference โ a sort-then-scan greedy classic.
Select the maximum number of non-overlapping activities โ the canonical greedy interval scheduling problem.
Maximize value in a knapsack where items can be broken into fractions โ greedily pick by value/weight ratio.
Determine if you can reach the last index by greedily tracking the farthest reachable position.
Find the unique starting gas station from which you can complete a circular route without running out of fuel.
Remove the minimum number of intervals to make the rest non-overlapping โ greedy sorting by end time.
Find the minimum number of arrows needed to burst all balloons on a wall โ greedy interval overlap.
Split a string into as many parts as possible so each character appears in at most one part.
Schedule jobs to maximize total profit given each job has a deadline and takes one unit of time.
Build an optimal prefix-free encoding tree by greedily merging the two lowest-frequency symbols.
Find the minimum number of railway platforms needed so no train waits โ a classic interval greedy problem.
Find the minimum cost to connect all ropes into one by always combining the two shortest โ greedy min-heap.
Rearrange a string so no two adjacent characters are the same โ greedy placement using a max-frequency heap.
Remove k digits from a number string to produce the smallest possible resulting number โ monotonic stack greedy.
Maximize the number of courses you can take given duration and deadline constraints โ greedy with a max-heap.