Practice these problems to strengthen your understanding of data structures and algorithms. Filter by difficulty, category, or search for specific problems.
Practice these problems to strengthen your understanding of data structures and algorithms.
Showing 87 of 87 problems
Find the minimum length of a string after repeatedly removing equal characters from both ends.
Rearrange characters in a string so that no two adjacent characters are the same.
Find the k most frequent words in an array, sorted by frequency and alphabetically.
Sort characters in a string based on their frequency of occurrence.
Determine if two sentences can be made identical by inserting additional words into one of them.
Determine if a string reads the same forward and backward.
Determine if one string is a scrambled version of another string.
Reverse a string to create a simple encryption system.
Check if two strings are anagrams of each other.
Find the longest common prefix among a set of strings.
Compress a string by replacing repeated characters with counts.
Implement a pattern matching algorithm for filtering emails.
Calculate the factorial of a number using recursion.
Generate the Fibonacci sequence using recursion.
Implement a binary search algorithm to find a book's position in a sorted catalog.
Solve the Tower of Hanoi puzzle using recursion.
Implement a flood fill algorithm for a digital art application's paint bucket tool.
Generate all possible permutations of a set.
Find if there exists a subset of elements that sum to a target value.
Find the nth number whose prime factors are limited to 2, 3, and 5.
Find the maximum number of coins you can collect by bursting balloons in the optimal order.
Find the length of the longest increasing path in a matrix where you can move in four directions.
Find the nth super ugly number in a sequence where each number's prime factors are limited to a specific set.
Determine the total number of ways to decode a message where letters are represented by numbers.
Calculate the number of structurally unique binary search trees that can be formed with n nodes.
Count the number of distinct subsequences of one string that equal another string.
Generate the first n rows of Pascal's Triangle, where each number is the sum of the two numbers directly above it.
Return a specific row from Pascal's Triangle efficiently without generating the entire triangle.
Find the largest rectangle containing only 1's in a binary matrix.
Implement a regular expression matcher with support for '.' and '*' patterns.
Count ways to paint an m×n grid with three colors such that no adjacent cells have the same color.
Find the length of the longest valid parentheses substring.
Count the number of special subsequences in a binary array.
Calculate how much rainwater can be trapped between buildings of varying heights.
Implement a wildcard pattern matcher with support for '?' and '*' patterns.
Form the largest integer with digits that add up to a target sum.
Find the largest plus sign of 1's in a grid of 0's and 1's.
Find the length of the longest palindromic subsequence in a string.
Find the longest palindromic substring in a string.
Find the maximum sum of a subarray with at most one element deletion.
Find the length of the longest Fibonacci subsequence in an array.
Make an array strictly increasing by replacing elements.
Count the number of ways to climb a staircase taking 1 or 2 steps at a time.
Find the maximum amount of money you can rob without alerting the police.
Rob houses arranged in a circle without alerting the police.
Count the number of unique paths from top-left to bottom-right of a grid.
Count unique paths in a grid with obstacles.
Find the path with the minimum sum from top-left to bottom-right in a grid.
Find the number of ways to assign + and - to reach a target sum.
Determine if an array can be partitioned into two equal sum subsets.
Find the maximum number of strings that can be formed with given limits of 0s and 1s.
Find the length of the longest turbulent subarray.
Find the minimum number of insertions needed to make a string palindromic.
Count the number of strings of length n that consist only of vowels and follow specific rules.
Count the number of distinct sequences that can be obtained with dice rolls.
Count the number of ways to tile a 2 x n board with dominos and trominos.
Find the maximum profit from buying and selling a stock once.
Find the maximum profit from buying and selling stocks with at most two transactions.
Find the maximum profit from buying and selling stocks with at most k transactions.
Find the maximum profit with a cooldown period after selling.
Find the maximum profit with a transaction fee for each trade.
Find the maximum score of a team with no age-score conflicts.
Count the number of distinct phone numbers of length n that a chess knight can dial.
Calculate the probability that a knight remains on the board after k moves.
Count the number of paths to move a ball out of a grid boundary.
Sort an array using only pancake flips, where a pancake flip reverses the first k elements of the array.
Maximize your score by strategically playing tokens either face up or face down.
Determine the minimum number of boats required to rescue everyone, where each boat can carry at most 2 people.
Find the maximum sum of satisfaction you can get by cooking some dishes.
Design a data structure that can efficiently add numbers from a data stream and find the median of all numbers added so far.
Maximize capital by selecting projects with the highest profit that can be started with the current capital.
Find the kth largest element in an unsorted array without sorting the entire array.
Find the k closest points to the origin (0, 0) in a 2D plane.
Design a class to find the kth largest element in a stream of numbers.
Rotate an array to the right by k steps, where elements that would go beyond the end wrap around to the beginning.
Determine if a non-negative integer can be expressed as the sum of two perfect squares.
Find the minimum number of operations to get n 'A's using copy and paste.
Collect maximum cherries in a grid by making two passes.
Collect maximum cherries with two robots moving simultaneously.
Count the number of possible combinations that add up to a target.
Count the number of ways to get a target sum with n dice rolls.
Count the number of profitable schemes with given constraints.
Find the lowest price to buy items with special offers.
Calculate the probability of serving soup in a specific order.
Find the tallest billboard possible with given rods.
Practice these problems to strengthen your understanding of data structures and algorithms. Filter by difficulty, category, or search for specific problems.
Practice these problems to strengthen your understanding of data structures and algorithms.
Showing 87 of 87 problems
Find the minimum length of a string after repeatedly removing equal characters from both ends.
Rearrange characters in a string so that no two adjacent characters are the same.
Find the k most frequent words in an array, sorted by frequency and alphabetically.
Sort characters in a string based on their frequency of occurrence.
Determine if two sentences can be made identical by inserting additional words into one of them.
Determine if a string reads the same forward and backward.
Determine if one string is a scrambled version of another string.
Reverse a string to create a simple encryption system.
Check if two strings are anagrams of each other.
Find the longest common prefix among a set of strings.
Compress a string by replacing repeated characters with counts.
Implement a pattern matching algorithm for filtering emails.
Calculate the factorial of a number using recursion.
Generate the Fibonacci sequence using recursion.
Implement a binary search algorithm to find a book's position in a sorted catalog.
Solve the Tower of Hanoi puzzle using recursion.
Implement a flood fill algorithm for a digital art application's paint bucket tool.
Generate all possible permutations of a set.
Find if there exists a subset of elements that sum to a target value.
Find the nth number whose prime factors are limited to 2, 3, and 5.
Find the maximum number of coins you can collect by bursting balloons in the optimal order.
Find the length of the longest increasing path in a matrix where you can move in four directions.
Find the nth super ugly number in a sequence where each number's prime factors are limited to a specific set.
Determine the total number of ways to decode a message where letters are represented by numbers.
Calculate the number of structurally unique binary search trees that can be formed with n nodes.
Count the number of distinct subsequences of one string that equal another string.
Generate the first n rows of Pascal's Triangle, where each number is the sum of the two numbers directly above it.
Return a specific row from Pascal's Triangle efficiently without generating the entire triangle.
Find the largest rectangle containing only 1's in a binary matrix.
Implement a regular expression matcher with support for '.' and '*' patterns.
Count ways to paint an m×n grid with three colors such that no adjacent cells have the same color.
Find the length of the longest valid parentheses substring.
Count the number of special subsequences in a binary array.
Calculate how much rainwater can be trapped between buildings of varying heights.
Implement a wildcard pattern matcher with support for '?' and '*' patterns.
Form the largest integer with digits that add up to a target sum.
Find the largest plus sign of 1's in a grid of 0's and 1's.
Find the length of the longest palindromic subsequence in a string.
Find the longest palindromic substring in a string.
Find the maximum sum of a subarray with at most one element deletion.
Find the length of the longest Fibonacci subsequence in an array.
Make an array strictly increasing by replacing elements.
Count the number of ways to climb a staircase taking 1 or 2 steps at a time.
Find the maximum amount of money you can rob without alerting the police.
Rob houses arranged in a circle without alerting the police.
Count the number of unique paths from top-left to bottom-right of a grid.
Count unique paths in a grid with obstacles.
Find the path with the minimum sum from top-left to bottom-right in a grid.
Find the number of ways to assign + and - to reach a target sum.
Determine if an array can be partitioned into two equal sum subsets.
Find the maximum number of strings that can be formed with given limits of 0s and 1s.
Find the length of the longest turbulent subarray.
Find the minimum number of insertions needed to make a string palindromic.
Count the number of strings of length n that consist only of vowels and follow specific rules.
Count the number of distinct sequences that can be obtained with dice rolls.
Count the number of ways to tile a 2 x n board with dominos and trominos.
Find the maximum profit from buying and selling a stock once.
Find the maximum profit from buying and selling stocks with at most two transactions.
Find the maximum profit from buying and selling stocks with at most k transactions.
Find the maximum profit with a cooldown period after selling.
Find the maximum profit with a transaction fee for each trade.
Find the maximum score of a team with no age-score conflicts.
Count the number of distinct phone numbers of length n that a chess knight can dial.
Calculate the probability that a knight remains on the board after k moves.
Count the number of paths to move a ball out of a grid boundary.
Sort an array using only pancake flips, where a pancake flip reverses the first k elements of the array.
Maximize your score by strategically playing tokens either face up or face down.
Determine the minimum number of boats required to rescue everyone, where each boat can carry at most 2 people.
Find the maximum sum of satisfaction you can get by cooking some dishes.
Design a data structure that can efficiently add numbers from a data stream and find the median of all numbers added so far.
Maximize capital by selecting projects with the highest profit that can be started with the current capital.
Find the kth largest element in an unsorted array without sorting the entire array.
Find the k closest points to the origin (0, 0) in a 2D plane.
Design a class to find the kth largest element in a stream of numbers.
Rotate an array to the right by k steps, where elements that would go beyond the end wrap around to the beginning.
Determine if a non-negative integer can be expressed as the sum of two perfect squares.
Find the minimum number of operations to get n 'A's using copy and paste.
Collect maximum cherries in a grid by making two passes.
Collect maximum cherries with two robots moving simultaneously.
Count the number of possible combinations that add up to a target.
Count the number of ways to get a target sum with n dice rolls.
Count the number of profitable schemes with given constraints.
Find the lowest price to buy items with special offers.
Calculate the probability of serving soup in a specific order.
Find the tallest billboard possible with given rods.