Hard Problems
679 problems
This track helps you build stable solving and explanation quality at this pressure level.
Training Focus
Stress-test edge reasoning and optimization depth.
Cadence
Run 3-5 problems per round: explain, implement, then review failure paths.
Pair With
Pair this track with topic and pattern pages for faster transfer learning.
Median of Two Sorted Arrays
Find the median of two sorted arrays using binary search for efficient O(log(min(m, n))) time complexity.
Regular Expression Matching
The Regular Expression Matching problem involves checking if a string matches a pattern using '.' and '*'.
Merge k Sorted Lists
Merge k Sorted Lists requires efficiently combining multiple sorted linked lists into one using pointers and priority qu…
Reverse Nodes in k-Group
Reverse Nodes in k-Group challenges you to reverse segments of a linked list in groups of size k.
Substring with Concatenation of All Words
Find all starting indices of substrings in a string that are concatenations of a given list of words.
Longest Valid Parentheses
Compute the length of the longest well-formed parentheses substring using state transition dynamic programming and stack…
Sudoku Solver
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
First Missing Positive
Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…
Trapping Rain Water
Calculate the total trapped rain water using the elevation map array, leveraging dynamic programming and two-pointer pat…
Wildcard Matching
Implement full wildcard pattern matching using '?' and '*' by applying state transition dynamic programming with careful…
N-Queens
Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…
N-Queens II
Solve the N-Queens II problem using backtracking with pruning to efficiently count all valid placements for n queens on …
Permutation Sequence
Find the kth permutation sequence of a set of numbers using math and recursion to efficiently compute the result.
Valid Number
Determine if a given string represents a valid number using precise string parsing and character validation rules.
Text Justification
Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.
Minimum Window Substring
Find the smallest substring of s containing all characters from t using a sliding window with running state updates for …
Largest Rectangle in Histogram
Find the maximal rectangular area in a histogram using stack-based state management for precise bar tracking and width c…
Maximal Rectangle
Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…
Scramble String
Scramble String is a dynamic programming problem where we determine if one string can be scrambled to form another using…
Distinct Subsequences
Compute the number of distinct subsequences of one string matching another using precise state transition dynamic progra…
Best Time to Buy and Sell Stock III
Determine the maximum profit from at most two stock transactions using state transition dynamic programming on price arr…
Binary Tree Maximum Path Sum
Calculate the maximum sum of any path in a binary tree by exploring all node sequences using DFS and dynamic programming…
Word Ladder II
Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …
Word Ladder
Find the shortest transformation sequence from a start word to an end word, with each word in the sequence differing by …
Palindrome Partitioning II
Determine the minimum cuts required to partition a string into all palindromic substrings using dynamic programming tech…
Candy
The Candy problem is a greedy algorithm challenge where you need to minimize candy distribution while satisfying certain…
Word Break II
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
Max Points on a Line
Find the maximum number of points on a straight line in a 2D plane using array scanning and hash lookup.
Find Minimum in Rotated Sorted Array II
Find the minimum in a rotated sorted array with possible duplicates using binary search.
Dungeon Game
Calculate the minimum initial health the knight needs to survive the dungeon using state transition dynamic programming …
Best Time to Buy and Sell Stock IV
Determine the maximum profit from at most k stock transactions using state transition dynamic programming on an array of…
Word Search II
Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.
Shortest Palindrome
The Shortest Palindrome problem asks to transform a string into a palindrome by adding characters at the beginning, with…
The Skyline Problem
The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …
Contains Duplicate III
The problem involves finding a pair of indices in an array where the index and value differences are within given limits…
Basic Calculator
Implement a basic calculator to evaluate mathematical expressions, ensuring correct evaluation with stack-based manageme…
Number of Digit One
Compute the total number of digit one appearing in all numbers from 0 up to n using state transition dynamic programming…
Sliding Window Maximum
Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…
Integer to English Words
Convert a given integer to its English words representation using mathematical logic and string manipulation.
Expression Add Operators
Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…
Find Median from Data Stream
Implement a MedianFinder class that supports adding numbers and finding the median from a data stream.
Serialize and Deserialize Binary Tree
This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…
Remove Invalid Parentheses
Remove the minimum number of invalid parentheses to generate all possible valid strings efficiently using backtracking a…
Burst Balloons
Burst Balloons is a hard dynamic programming problem requiring careful state transitions to maximize coins collected eff…
Count of Smaller Numbers After Self
Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.
Create Maximum Number
Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.
Count of Range Sum
Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…
Longest Increasing Path in a Matrix
Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.
Patching Array
Patching Array requires adding the minimum numbers to cover all sums from 1 to n using greedy choices and invariant chec…
Reconstruct Itinerary
Reconstruct Itinerary requires building a valid travel route using all tickets once, starting from JFK with lexical orde…
Self Crossing
Determine if a path defined by sequential distances on a 2D plane crosses itself using array and math reasoning.
Palindrome Pairs
Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.
Data Stream as Disjoint Intervals
The problem involves designing a class to summarize a data stream of non-negative integers as disjoint intervals using b…
Russian Doll Envelopes
Russian Doll Envelopes is a dynamic programming problem that involves finding the longest chain of envelopes that can be…
Max Sum of Rectangle No Larger Than K
Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…
Insert Delete GetRandom O(1) - Duplicates allowed
This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…
Perfect Rectangle
Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…
Frog Jump
Determine if a frog can cross a river using jumps constrained by previous step sizes in a dynamic programming state tran…
Trapping Rain Water II
Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.
Split Array Largest Sum
Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…
Strong Password Checker
The Strong Password Checker problem challenges you to optimize password strength while minimizing steps using greedy alg…
All O`one Data Structure
Implement a data structure that tracks string counts and retrieves max or min keys efficiently in constant time.
K-th Smallest in Lexicographical Order
Find the k-th lexicographically smallest integer in a range using a Trie-based approach.
Arithmetic Slices II - Subsequence
Count all arithmetic subsequences in an array using dynamic programming with precise state transitions for correctness.
Poor Pigs
Find the minimum number of pigs required to determine the poisonous bucket within a set time using state transition dyna…
LFU Cache
Implement an LFU Cache using linked-list pointer manipulation with constant-time get and put operations for interview sc…
Count The Repetitions
This problem requires counting how many times a repeated string s2 fits as a subsequence within a repeated string s1 usi…
Concatenated Words
Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …
Largest Palindrome Product
Find the largest palindromic number from the product of two n-digit integers using math and enumeration efficiently.
Sliding Window Median
Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…
Smallest Good Base
Find the smallest good base of an integer n using binary search over the valid answer space.
Zuma Game
The Zuma Game involves clearing balls from the board using a limited hand, applying dynamic programming and state transi…
Reverse Pairs
Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.
IPO
Maximize total capital by selecting up to k projects, based on initial capital and project profits using a greedy strate…
Freedom Trail
Determine the minimum rotations and button presses to spell a keyword on a circular dial using state transition dynamic …
Super Washing Machines
Calculate the minimum moves to balance dresses across washing machines using a greedy strategy and invariant validation …
Remove Boxes
Maximize points by strategically removing contiguous same-colored boxes using state transition dynamic programming and m…
Student Attendance Record II
The Student Attendance Record II problem explores counting valid student attendance sequences using dynamic programming …
Find the Closest Palindrome
Identify the nearest palindrome to a given integer string, handling ties and large numbers efficiently using math and st…
Erect the Fence
Find the perimeter fence of a garden by determining the outermost trees in a set of given tree coordinates.
Tag Validator
The Tag Validator problem involves validating a code snippet by parsing through tags using a stack-based state managemen…
Non-negative Integers without Consecutive Ones
Count non-negative integers up to n without consecutive ones in their binary representation using dynamic programming.
K Inverse Pairs Array
The K Inverse Pairs Array problem focuses on counting arrays with exactly k inverse pairs using dynamic programming.
Course Schedule III
Solve the 'Course Schedule III' problem with a greedy approach involving course selection and validation of constraints.
Smallest Range Covering Elements from K Lists
Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…
Decode Ways II
Decode Ways II is a challenging dynamic programming problem that involves decoding messages with digits and wildcard cha…
Strange Printer
Calculate the minimum turns a strange printer needs to print any string using state transition dynamic programming effic…
Kth Smallest Number in Multiplication Table
Find the kth smallest number in an m x n multiplication table using binary search over the valid answer space.
Cut Off Trees for Golf Event
Determine the minimum steps to cut all trees in a forest matrix in ascending height order using BFS traversal and priori…
24 Game
Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…
Redundant Connection II
Find and remove the redundant connection in a directed graph that was originally a rooted tree.
Maximum Sum of 3 Non-Overlapping Subarrays
Maximize the sum of three non-overlapping subarrays with length k in an integer array using dynamic programming.
Stickers to Spell Word
Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…
Falling Squares
Solve Falling Squares by efficiently computing maximum stack heights using arrays with segment tree optimization techniq…
Random Pick with Blacklist
Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…
Range Module
Design a RangeModule to track and query half-open intervals using segment trees or ordered sets.
Find K-th Smallest Pair Distance
Solve Find K-th Smallest Pair Distance by sorting nums, then binary searching the distance and counting valid pairs with…
Number of Atoms
Compute the exact count of each atom in a chemical formula using stack-based state management and hashing techniques eff…
Count Different Palindromic Subsequences
Count Different Palindromic Subsequences leverages dynamic programming to count non-empty palindromic subsequences in a …
My Calendar III
Implement My Calendar III to track maximum overlapping events efficiently using binary search and segment tree technique…
Parse Lisp Expression
Parse Lisp expressions using stack-based state management to evaluate variables and operations.
Cherry Pickup
Maximize cherries collected on a grid, employing state transition dynamic programming with careful navigation across obs…
Prefix and Suffix Search
Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.
Contain Virus
Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…
Cracking the Safe
The Cracking the Safe problem involves finding the shortest password sequence to unlock a safe using graph traversal and…
Set Intersection Size At Least Two
Solve the Set Intersection Size At Least Two problem using a greedy approach and invariant validation.
Special Binary String
Solve the Special Binary String problem using string manipulation and recursion, optimizing lexicographical order.
Couples Holding Hands
This problem requires arranging couples sitting apart in a row with the minimum number of swaps using graph traversal an…
Max Chunks To Make Sorted II
Determine the maximum number of chunks you can split an array into so that sorting each chunk results in a fully sorted …
Basic Calculator IV
Simplify mathematical expressions using stack-based state management, handling variables, operators, and polynomial term…
Sliding Puzzle
Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …
Swim in Rising Water
Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.
Reaching Points
Determine whether it is possible to reach a target point from a start point using repeated additive moves following stri…
Transform to Chessboard
Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.
Preimage Size of Factorial Zeroes Function
Solve for the number of integers whose factorial ends with a specific number of zeroes using binary search techniques.
Smallest Rotation with Highest Score
Find the smallest rotation index with the highest score using array and prefix sum techniques.
Minimum Swaps To Make Sequences Increasing
This problem involves finding the minimum number of swaps needed to make two sequences strictly increasing using dynamic…
Bricks Falling When Hit
Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.
Split Array With Same Average
Determine whether an integer array can be partitioned into two non-empty subarrays with the same average using dynamic p…
Chalkboard XOR Game
The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…
Bus Routes
Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.
Race Car
Race Car is a dynamic programming problem where the goal is to find the shortest sequence of instructions to reach a tar…
Making A Large Island
Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…
Count Unique Characters of All Substrings of a Given String
Calculate the sum of unique characters in all substrings of a string using state transition dynamic programming.
Consecutive Numbers Sum
Find the number of ways to express a number as the sum of consecutive positive integers.
Sum of Distances in Tree
The problem asks to compute the sum of distances between each node and all others in a tree structure using depth-first …
Similar String Groups
Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…
Guess the Word
Master the Guess the Word problem by applying array manipulation, match-counting math, and strategic interactive guessin…
Shortest Path Visiting All Nodes
Solve the Shortest Path Visiting All Nodes problem by exploring dynamic programming, bit manipulation, and breadth-first…
Rectangle Area II
The problem involves calculating the total area covered by multiple rectangles, ensuring overlap is counted only once.
K-Similar Strings
K-Similar Strings involves finding the minimal number of swaps to transform one string into another through character sw…
Minimum Cost to Hire K Workers
Find the minimum cost to hire exactly k workers based on quality and wage expectations in this challenging greedy proble…
Shortest Subarray with Sum at Least K
Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.
Shortest Path to Get All Keys
Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.
Minimum Number of Refueling Stops
Determine the minimum number of refueling stops needed to reach a target using dynamic programming and greedy strategies…
Nth Magical Number
Find the nth magical number divisible by a or b, using binary search to efficiently handle large inputs.
Profitable Schemes
Given a group of members and a list of crimes, count the profitable schemes that meet the profit and group constraints.
Reachable Nodes In Subdivided Graph
The Reachable Nodes In Subdivided Graph problem requires efficiently finding the reachable nodes using graph traversal a…
Super Egg Drop
Solve the Super Egg Drop problem using dynamic programming and binary search to minimize the number of moves required to…
Sum of Subsequence Widths
Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.
Maximum Frequency Stack
Design a stack-like data structure to manage elements and handle frequent stack operations, including popping the most f…
Orderly Queue
Given a string and integer k, rearrange characters to achieve the lexicographically smallest string using limited rotati…
Numbers At Most N Given Digit Set
The 'Numbers At Most N Given Digit Set' problem requires calculating how many numbers can be formed using a given digit …
Valid Permutations for DI Sequence
The problem asks to find the number of valid permutations for a given DI sequence string using dynamic programming and s…
Super Palindromes
Count all super-palindromes in a given numeric range, where each is a palindrome and square of a palindrome.
Cat and Mouse
Determine the outcome of a two-player Cat and Mouse game on a graph using topological ordering and memoized dynamic prog…
Number of Music Playlists
Solve the Number of Music Playlists problem with dynamic programming, focusing on state transitions and combinatorics to…
Minimize Malware Spread
Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.
Three Equal Parts
Divide a binary array into three contiguous parts such that each part represents the same integer value in binary, using…
Minimize Malware Spread II
Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.
Stamping The Sequence
Solve Stamping The Sequence with stack-based state management to convert string s to target using stamp efficiently.
Distinct Subsequences II
Find the number of distinct non-empty subsequences of a string using dynamic programming and state transitions.
Find the Shortest Superstring
This problem requires constructing the shortest string containing all input words using state transition dynamic program…
Largest Component Size by Common Factor
Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …
Tallest Billboard
Solve the Tallest Billboard problem by using dynamic programming to find the maximum equal height for two disjoint rod s…
Delete Columns to Make Sorted III
The problem requires minimizing deletions to ensure all strings are lexicographically sorted. Use dynamic programming fo…
Least Operators to Express Number
Compute the minimum number of arithmetic operators to form a target using repeated x with addition, subtraction, multipl…
Binary Tree Cameras
Determine the minimum number of cameras required to monitor every node in a binary tree using efficient DFS and state tr…
Equal Rational Numbers
Given two rational numbers as strings with possible repeating decimals, determine if they represent the same number.
Odd Even Jump
Determine the number of valid starting indices in an array where you can reach the end with alternating odd and even jum…
Unique Paths III
Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…
Triples with Bitwise AND Equal To Zero
Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…
Vertical Order Traversal of a Binary Tree
Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.
Subarrays with K Different Integers
Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.
Minimum Number of K Consecutive Bit Flips
Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…
Number of Squareful Arrays
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
Minimum Cost to Merge Stones
Minimize the cost to merge stones with k consecutive piles using dynamic programming to achieve the optimal solution.
Grid Illumination
Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …
Numbers With Repeated Digits
Solve Numbers With Repeated Digits by counting unique-digit numbers up to n, then subtracting from n using digit DP.
Recover a Tree From Preorder Traversal
Recover a binary tree from its preorder traversal string by tracking node depth and reconstructing child relationships e…
Stream of Characters
Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…
Escape a Large Maze
The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…
Longest Duplicate Substring
Find the longest duplicated substring in a string using binary search, sliding window, and rolling hash techniques.
Number of Submatrices That Sum to Target
Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…
Shortest Common Supersequence
Compute the shortest string containing both given strings as subsequences using state transition dynamic programming eff…
Find in Mountain Array
Find in Mountain Array requires locating a target using binary search over a peak-structured array efficiently in intera…
Brace Expansion II
Solve Brace Expansion II efficiently by using stack-based state management to generate all unique combinations of nested…
Parsing A Boolean Expression
Solve the "Parsing A Boolean Expression" problem by evaluating boolean expressions using stack-based state management, r…
Smallest Sufficient Team
Find the smallest subset of people covering all required skills using bitmask dynamic programming for efficient state tr…
Longest Chunked Palindrome Decomposition
Solve the "Longest Chunked Palindrome Decomposition" problem by using dynamic programming and string manipulation techni…
Online Majority Element In Subarray
Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.
Last Substring in Lexicographical Order
Identify the lexicographically last substring in a string using two-pointer scanning with invariant tracking efficiently…
Dinner Plate Stacks
Design a system that manages dinner plate stacks using stack-based state management, handling dynamic plate placement an…
Number of Valid Words for Each Puzzle
Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…
Make Array Strictly Increasing
Determine the minimum operations to transform arr1 into a strictly increasing sequence using values from arr2 efficientl…
Critical Connections in a Network
Find critical connections in a network of servers, ensuring efficient traversal using depth-first search and Tarjan's al…
Sort Items by Groups Respecting Dependencies
Sort items into groups while respecting dependencies using graph indegree tracking and topological ordering patterns eff…
Design Skiplist
Implement a Skiplist efficiently using linked-list pointer manipulation to support search, add, and erase operations in …
Minimum Moves to Reach Target with Rotations
Find the minimum moves for a 2-cell snake to reach the bottom-right corner using rotations and BFS traversal in a grid.
Count Vowels Permutation
Count Vowels Permutation requires computing the number of valid vowel strings of length n using state transition dynamic…
Dice Roll Simulation
Calculate all valid sequences of n dice rolls with consecutive roll constraints using state transition dynamic programmi…
Maximum Equal Frequency
Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…
Maximum Profit in Job Scheduling
Compute the maximum profit from non-overlapping jobs using state transition dynamic programming with sorted arrays and b…
Tiling a Rectangle with the Fewest Squares
Tiling a Rectangle with the Fewest Squares problem asks for the minimum number of squares required to cover a rectangle …
Check If It Is a Good Array
Determine if a given array of positive integers can generate 1 using integer multiples of any subset, leveraging number …
Maximum Score Words Formed by Letters
Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…
Minimum Moves to Move a Box to Their Target Location
Solve the minimum moves to push a box to its target using BFS and priority handling in a grid-based warehouse layout eff…
Number of Ways to Stay in the Same Place After Some Steps
Compute the exact number of ways to remain at index 0 after given steps using state transition dynamic programming.
Palindrome Partitioning III
Find the minimal character changes to split a string into k palindromes using precise dynamic programming state transiti…
Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…
Minimum Falling Path Sum II
Find the minimum sum of a falling path in a square matrix using dynamic programming while avoiding same-column selection…
Shortest Path in a Grid with Obstacles Elimination
Find the shortest path in a grid with obstacles, allowing the elimination of up to k obstacles using BFS.
Maximum Candies You Can Get from Boxes
Collect maximum candies from boxes by exploring initially available boxes and using keys to unlock additional ones effic…
Number of Paths with Max Score
Calculate the maximum score path and count all valid routes in a square board with obstacles using dynamic programming.
Verbal Arithmetic Puzzle
Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.
Minimum Insertion Steps to Make a String Palindrome
The problem asks to find the minimum number of insertions to convert a string into a palindrome using dynamic programmin…
Distinct Echo Substrings
Count the distinct non-empty substrings of a given string that can be formed as the concatenation of a string with itsel…
Minimum Distance to Type a Word Using Two Fingers
Calculate the minimum total distance to type a word using two fingers on a keyboard, applying dynamic programming.
Minimum Number of Taps to Open to Water a Garden
Determine the minimum number of taps to water an entire garden using state transition dynamic programming and interval c…
Reverse Subarray To Maximize Array Value
Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.
Minimum Difficulty of a Job Schedule
Schedule jobs into multiple days to minimize the difficulty of the schedule using dynamic programming and state transiti…
Jump Game V
Jump Game V is a hard dynamic programming problem that focuses on maximizing jumps between indices in an array.
Jump Game IV
Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…
Maximum Students Taking Exam
Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…
Construct Target Array With Multiple Sums
This problem requires constructing a target array from an array of ones, using multiple sum operations and a priority qu…
Count All Valid Pickup and Delivery Options
Count all valid pickup and delivery sequences for n orders where deliveries occur after pickups using dynamic programmin…
Largest Multiple of Three
Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…
Minimum Cost to Make at Least One Valid Path in a Grid
Determine the minimum cost to create at least one valid path from the top-left to bottom-right in a directional grid.
Maximum Sum BST in Binary Tree
Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.
Frog Position After T Seconds
The problem asks for the probability that a frog reaches a target vertex after t seconds in a tree graph.
Maximum Performance of a Team
Maximize the performance of a team by selecting up to k engineers with the highest performance based on speed and effici…
Pizza With 3n Slices
Maximize your pizza slice sum from a 3n-sized circular array using state transition dynamic programming efficiently.
Longest Happy Prefix
Find the longest non-empty prefix of a string that also appears as its suffix, optimizing with rolling hash techniques.
Find All Good Strings
Find all good strings between two given strings without including a specified evil substring using dynamic programming.
Reducing Dishes
Maximize the sum of like-time coefficients by optimally choosing dishes to prepare in this dynamic programming problem.
Stone Game III
Stone Game III is a challenging dynamic programming problem based on game theory and state transition logic.
Number of Ways to Paint N × 3 Grid
Calculate the number of ways to paint a grid of size n x 3 with distinct adjacent colors using dynamic programming.
Restore The Array
Calculate the number of arrays that can be restored from a string of digits where each number is within [1, k].
Build Array Where You Can Find The Maximum Exactly K Comparisons
This problem asks to build an array where the maximum element is found using exactly K comparisons, with dynamic program…
Constrained Subsequence Sum
Solve the Constrained Subsequence Sum problem using dynamic programming, sliding window, and priority queues to maximize…
Number of Ways to Wear Different Hats to Each Other
Calculate all unique assignments of hats to people using state transition dynamic programming with bitmasking for collis…
Find the Kth Smallest Sum of a Matrix With Sorted Rows
Find the kth smallest sum in a matrix with sorted rows using binary search and a heap-based approach.
Number of Ways of Cutting a Pizza
This problem challenges you to determine the number of valid ways to cut a pizza into pieces with apples using dynamic p…
Form Largest Integer With Digits That Add up to Target
Maximize the integer you can paint with given digit costs under a target sum, using dynamic programming to optimize the …
Maximum Number of Darts Inside of a Circular Dartboard
Maximize the number of darts on a circular dartboard given dart positions and radius.
Max Dot Product of Two Subsequences
Solve Max Dot Product of Two Subsequences with state transition dynamic programming that enforces a non-empty pairing de…
Cherry Pickup II
Maximize cherry collection in a grid using two robots with careful state transition dynamic programming to optimize path…
Probability of a Two Boxes Having The Same Number of Distinct Balls
Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…
Paint House III
Solve Paint House III using state transition dynamic programming to minimize painting costs while forming exact neighbor…
Allocate Mailboxes
Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…
Kth Ancestor of a Tree Node
Find the kth ancestor of any node in a tree using efficient binary-tree traversal and dynamic state tracking methods.
Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
Identify critical and pseudo-critical edges in a weighted graph's minimum spanning tree using Union Find efficiently.
Parallel Courses II
Determine the minimum semesters to complete all courses with prerequisites using state transition dynamic programming an…
Max Value of Equation
Max Value of Equation asks to find the maximum value of a specific equation on a set of 2D points using sliding window t…
Minimum Possible Integer After at Most K Adjacent Swaps On Digits
Reorder digits using at most k adjacent swaps to produce the smallest possible integer, leveraging greedy selection effi…
Stone Game IV
Stone Game IV requires predicting the winner using state transition dynamic programming with careful consideration of pe…
Best Position for a Service Centre
Find the optimal service center position in a city by minimizing the sum of Euclidean distances to all customers.
Maximum Number of Non-Overlapping Substrings
Find the maximum number of non-overlapping substrings in a given string, ensuring no two substrings intersect unless one…
Find a Value of a Mysterious Function Closest to Target
In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.
Minimum Number of Increments on Subarrays to Form a Target Array
The problem asks for the minimum number of operations to transform an initial array of zeros into a target array using s…
String Compression II
Solve String Compression II with dynamic programming that tracks deletions, run boundaries, and digit-length jumps in co…
Get the Maximum Score
Find the maximum possible score from two sorted arrays with a dynamic programming approach, leveraging partitioning and …
Find Longest Awesome Substring
Find the maximum-length awesome substring in a numeric string using hash table and bit manipulation for palindrome poten…
Minimum Cost to Cut a Stick
Find the minimum cost to cut a stick into segments at specified positions using dynamic programming and sorting.
Minimum Number of Days to Eat N Oranges
Find the minimum number of days to eat n oranges using state transition dynamic programming with memoization.
Stone Game V
In Stone Game V, Alice divides stones into rows to maximize her score, using a dynamic programming approach to try all d…
Minimum Number of Days to Disconnect Island
Find the minimum number of days to disconnect an island in a grid using depth-first search.
Number of Ways to Reorder Array to Get Same BST
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
Count All Possible Routes
This problem requires counting all possible routes between cities using fuel efficiently with state transition dynamic p…
Remove Max Number of Edges to Keep Graph Fully Traversable
Maximize the number of edges that can be removed while keeping the graph fully traversable for both Alice and Bob.
Check If String Is Transformable With Substring Sort Operations
This problem requires checking if string 's' can be transformed into string 't' using substring sort operations.
Strange Printer II
Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…
Minimum Cost to Connect Two Groups of Points
Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.
Maximum Number of Achievable Transfer Requests
Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.
Find Servers That Handled Most Number of Requests
Given k servers and a series of requests, find the busiest server(s) using greedy strategies and efficient server tracki…
Maximum Number of Visible Points
Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…
Minimum One Bit Operations to Make Integers Zero
Compute the minimum number of one-bit operations to convert a given integer to zero using state transition dynamic progr…
Count Subtrees With Max Distance Between Cities
This problem asks you to count subtrees in a tree structure where the maximum distance between any two cities matches sp…
Fancy Sequence
Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…
Graph Connectivity With Threshold
In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…
Rank Transform of a Matrix
Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…
Number of Ways to Form a Target String Given a Dictionary
Calculate the number of ways to form a target string using words of equal length via state transition dynamic programmin…
Kth Smallest Instructions
Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…
Create Sorted Array through Instructions
The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.
Distribute Repeating Integers
Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…
Maximize Grid Happiness
Maximize Grid Happiness is a dynamic programming problem focusing on state transitions with bitmasking to maximize happi…
Minimum Initial Energy to Finish Tasks
Determine the minimum initial energy needed to finish all tasks using a greedy ordering based on required versus actual …
Minimum Number of Removals to Make Mountain Array
Solve the problem of finding the minimum number of removals to make a given array a mountain array using dynamic program…
Minimize Deviation in Array
Given a positive integer array, repeatedly double or halve elements to minimize the difference between its largest and s…
Minimum Incompatibility
Optimize the sum of incompatibilities when distributing an array into subsets with unique elements.
Delivering Boxes from Storage to Ports
Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…
Maximum Height by Stacking Cuboids
Maximize the height of stacked cuboids by strategically rotating and stacking them using dynamic programming.
Checking Existence of Edge Length Limited Paths
Solve the problem of checking if there exists a path between two nodes under edge length constraints using efficient tec…
Minimum Adjacent Swaps for K Consecutive Ones
Find the minimum number of adjacent swaps to gather k consecutive ones in a binary array using sliding window logic.
Maximum XOR With an Element From Array
Solve the Maximum XOR With an Element From Array problem by efficiently finding the maximum XOR for each query using bit…
Minimum Operations to Make a Subsequence
Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…
Number Of Ways To Reconstruct A Tree
Determine how many distinct rooted trees can be reconstructed from given node pairs using careful traversal and state tr…
Find Minimum Time to Finish All Jobs
Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…
Cat and Mouse II
Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…
Count Ways to Make Array With Product
Determine the number of arrays of size n where the product equals k using prime factorization and combinatorial DP techn…
Building Boxes
Optimize the number of boxes touching the floor in a cubic room using binary search to minimize floor occupancy.
Palindrome Partitioning IV
The Palindrome Partitioning IV problem asks you to determine if a string can be split into three palindromic substrings.
Maximum Number of Events That Can Be Attended II
Determine the maximum sum of event values you can collect by attending at most k non-overlapping events using DP.
Closest Subsequence Sum
Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…
Minimum Degree of a Connected Trio in a Graph
Find the minimum degree of a connected trio in a graph using enumeration over nodes and edges.
Tree of Coprimes
Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…
Maximum Score from Performing Multiplication Operations
Solve the Maximum Score from Performing Multiplication Operations problem using dynamic programming and state transition…
Maximize Palindrome Length From Subsequences
Maximize Palindrome Length From Subsequences explores dynamic programming to construct the longest palindrome from two s…
Car Fleet II
Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…
Count Pairs Of Nodes
Given a graph with nodes and edges, count pairs of nodes where the degree sum exceeds a given threshold for each query.
Make the XOR of All Segments Equal to Zero
Determine the minimum changes needed in an array so all size-k segments XOR to zero using DP and bit manipulation.
Maximum Score of a Good Subarray
Maximize the score of a good subarray using binary search to explore the valid answer space with a focus on two-pointer …
Maximize Score After N Operations
Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …
Count Pairs With XOR in a Range
Count all pairs in an array whose XOR falls within a given range using efficient bit manipulation techniques and a trie …
Maximize Number of Nice Divisors
Solve Maximize Number of Nice Divisors by splitting primeFactors into mostly 3s and using fast modular exponentiation.
Maximum Number of Groups Getting Fresh Donuts
Reorder groups to maximize happy customers by using state transition dynamic programming with bitmasking for optimal bat…
Number of Different Subsequences GCDs
Given an array of positive integers, find the number of different subsequences' GCDs.
Finding MK Average
Find the MKAverage of a stream of integers using a queue-driven approach with efficient state management.
Minimum Number of Operations to Make String Sorted
Calculate the minimum operations to sort a string using combinatorial math and string manipulation techniques efficientl…
Find XOR Sum of All Pairs Bitwise AND
Compute the XOR sum of all pairwise ANDs between two integer arrays using array and bitwise math techniques efficiently.
Maximum Building Height
Find the maximum building height in a city given height restrictions for specific buildings.
Closest Room
Find the closest hotel room meeting minimum size requirements using binary search over the valid answer space efficientl…
Minimum Interval to Include Each Query
Find the smallest interval containing each query efficiently using binary search.
Largest Color Value in a Directed Graph
Compute the maximum color frequency along any valid path in a directed graph using topological ordering and dynamic prog…
Sum of Floored Pairs
The problem asks to calculate the sum of floor divisions for all pairs in a given integer array, using an efficient meth…
Number of Ways to Rearrange Sticks With K Sticks Visible
Calculate the number of arrangements of n uniquely-sized sticks so exactly k sticks are visible using dynamic programmin…
Stone Game VIII
Stone Game VIII requires calculating maximum score difference using state transition dynamic programming on prefix sums …
Minimum XOR Sum of Two Arrays
Minimize the XOR sum of two integer arrays by rearranging elements using dynamic programming and bit manipulation.
Minimum Skips to Arrive at Meeting On Time
Solve the problem of minimizing skips while traveling to arrive on time, using dynamic programming and state transitions…
Minimum Space Wasted From Packaging
Minimize the wasted space when packaging items into boxes, considering package and box size constraints.
Minimum Cost to Change the Final Value of Expression
Determine the minimum operations to change a boolean expression's result using state transition dynamic programming effi…
The Earliest and Latest Rounds Where Players Compete
This problem requires finding the earliest and latest rounds where two players compete using dynamic programming with st…
Design Movie Rental System
Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.
Count Ways to Build Rooms in an Ant Colony
Solve the problem of counting distinct ways to build rooms in an ant colony using dynamic programming and topological or…
Longest Common Subpath
The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…
Minimum Cost to Reach Destination in Time
Minimize the travel cost in a graph while adhering to a time constraint using state transition dynamic programming.
Painting a Grid With Three Different Colors
Count the number of ways to paint a grid using three colors while ensuring adjacent cells have different colors.
Merge BSTs to Create Single BST
This problem asks you to merge multiple BSTs into a single valid BST by performing a series of operations.
Maximum Genetic Difference Query
Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.
Number of Visible People in a Queue
Compute how many people each person in a queue can see to their right using efficient stack-based state management.
Delete Duplicate Folders in System
Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…
Count Number of Special Subsequences
Learn to count all valid special subsequences in an array using state transition dynamic programming efficiently and cor…
Maximum Product of the Length of Two Palindromic Substrings
Find the maximum product of lengths of two non-overlapping odd-length palindromic substrings using string and rolling ha…
Find the Longest Valid Obstacle Course at Each Position
Compute the longest valid obstacle course at each position using binary search and careful array tracking techniques eff…
Last Day Where You Can Still Cross
Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.
Number of Ways to Separate Numbers
Calculate the number of valid non-decreasing integer sequences from a string using state transition dynamic programming …
Find Array Given Subset Sums
Reconstruct an array from given subset sums using divide and conquer approach and leveraging array properties.
Number of Unique Good Subsequences
Find the number of unique good subsequences of a binary string using dynamic programming and modular arithmetic.
The Number of Good Subsets
Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.
GCD Sort of an Array
The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.
Smallest Missing Genetic Value in Each Subtree
Determine the smallest missing genetic value in each subtree using binary-tree traversal and precise state tracking effi…
Minimum Number of Operations to Make Array Continuous
Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…
Longest Subsequence Repeated k Times
Find the longest subsequence repeated k times in a string using backtracking search with pruning.
The Score of Students Solving Math Expression
Calculate student scores for a single-digit math expression using state transition dynamic programming to track all vali…
Maximum Number of Ways to Partition an Array
Determine the maximum number of ways to split an array into equal sums using at most one element change, leveraging pref…
Smallest K-Length Subsequence With Occurrences of a Letter
Find the lexicographically smallest subsequence of length k with at least repetition occurrences of a given letter using…
Partition Array Into Two Arrays to Minimize Sum Difference
Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…
Kth Smallest Product of Two Sorted Arrays
Find the kth smallest product from two sorted arrays using binary search across possible product values efficiently.
Second Minimum Time to Reach Destination
Find the second minimum time to reach a destination using BFS while accounting for traffic signal delays in a graph trav…
Parallel Courses III
Solve Parallel Courses III by finding the minimum number of months to complete all courses using graph-based topological…
Number of Valid Move Combinations On Chessboard
Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…
Check if an Original String Exists Given Two Encoded Strings
Determine if there exists an original string that could produce both encoded inputs using state transition dynamic progr…
Maximum Path Quality of a Graph
Calculate the maximum path quality in a graph using backtracking and pruning to optimize node visits within time limits …
Maximum Number of Tasks You Can Assign
Maximize the number of tasks that can be completed by efficiently using workers and magical pills.
Process Restricted Friend Requests
Determine which friend requests can be accepted without violating direct or indirect restrictions using union-find logic…
Sum of k-Mirror Numbers
This problem requires finding the sum of the n smallest k-mirror numbers by generating palindromes in base-k and base-10…
Count Fertile Pyramids in a Land
Solve Count Fertile Pyramids in a Land with matrix DP that measures the tallest pyramid rooted at each fertile cell.
Find All People With Secret
Find all people who receive a secret through meetings using graph traversal with depth-first search efficiently and corr…
Valid Arrangement of Pairs
Given pairs of numbers, find a valid arrangement where each pair follows a specific condition.
Sequentially Ordinal Rank Tracker
Track rankings of locations with names and scores, adding new locations and retrieving top-ranked ones efficiently.
Maximum Fruits Harvested After at Most K Steps
Compute the maximum fruits collectable on an infinite line by moving at most k steps from a start position efficiently.
Minimum Operations to Make the Array K-Increasing
This problem requires finding the minimum number of operations to make an array K-increasing using binary search over th…
Abbreviating the Product of a Range
Calculate the abbreviated product of integers in a range efficiently using math-driven analysis of trailing zeros and si…
Recover the Original Array
Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…
Maximum Employees to Be Invited to a Meeting
Determine the maximum employees to invite based on favorite adjacency constraints using graph indegree and topological o…
Stamping the Grid
Determine if a binary grid can be fully covered using fixed-size stamps by applying a greedy placement and validation st…
Earliest Possible Day of Full Bloom
Find the earliest day where all flower seeds are blooming based on their planting and growth times, using a greedy strat…
Maximum Running Time of N Computers
Solve the problem of determining the maximum running time of n computers using a set of batteries.
Number of Ways to Divide a Long Corridor
Calculate the number of ways to split a corridor into sections with exactly two seats using dynamic programming efficien…
Maximum Good People Based on Statements
Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.
Find Substring With Given Hash Value
Locate the first substring of length k whose rolling hash matches the given hashValue using a sliding window approach.
Groups of Strings
Group words into connected sets using operations on characters with string and bit manipulation techniques.
Minimum Difference in Sums After Removal of Elements
Minimize the difference between sums after removing n elements from a 3n array by dividing the remaining elements into t…
Minimum Time to Remove All Cars Containing Illegal Goods
Determine the minimum time to remove all cars with illegal goods using state transition dynamic programming efficiently.
Maximum AND Sum of Array
Find the maximum AND sum by placing integers into limited slots using state transition dynamic programming efficiently.
Count Good Triplets in an Array
Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.
Count Array Pairs Divisible by K
Count Array Pairs Divisible by K requires counting index pairs whose products are divisible by a given number k.
Minimum Time to Finish the Race
Minimize the time to complete a race with tire swaps using dynamic programming and state transitions.
Minimum Number of Moves to Make Palindrome
The problem challenges you to find the minimum number of adjacent swaps to make a string a palindrome.
Replace Non-Coprime Numbers in Array
Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…
Minimum Weighted Subgraph With the Required Paths
Find the minimum weighted subgraph that connects three specified nodes in a directed graph with constraints.
Minimum White Tiles After Covering With Carpets
Find the minimum number of white tiles visible after optimally placing carpets using state transition dynamic programmin…
Longest Substring of One Repeating Character
Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…
Maximum Value of K Coins From Piles
Optimize coin selection across multiple piles using state transition dynamic programming to achieve the maximum wallet v…
Sum of Scores of Built Strings
Calculate the sum of scores of built strings by analyzing longest common prefixes with suffixes in a string using effici…
Encrypt and Decrypt Strings
The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …
Maximum Total Beauty of the Gardens
Determine the maximum total beauty of gardens by strategically planting flowers using binary search over achievable flow…
Maximum Score of a Node Sequence
Find the maximum score of a valid node sequence in an undirected graph with given node scores and edges.
Longest Path With Different Adjacent Characters
Find the longest path in a tree where adjacent nodes have different characters using graph DFS and topological reasoning…
Number of Flowers in Full Bloom
Find the number of flowers in full bloom at the given times for a list of people.
Escape the Spreading Fire
Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…
Total Appeal of A String
Calculate the total appeal of all substrings by counting distinct characters efficiently using state transition DP and h…
Check if There Is a Valid Parentheses String Path
Check if there exists a valid parentheses string path in a given grid using state transition dynamic programming.
Substring With Largest Variance
Find the largest variance possible in any substring of a given string using dynamic programming.
Count Integers in Intervals
Design and implement a data structure to efficiently add intervals and count the total number of integers covered by the…
Sum of Total Strength of Wizards
The Sum of Total Strength of Wizards problem asks for the sum of the total strengths of all contiguous subarrays of wiza…
Booking Concert Tickets in Groups
Design a ticketing system to allocate concert seats in specific groupings while efficiently handling seat reservations.
Minimum Obstacle Removal to Reach Corner
Find the minimum obstacles to remove in a 2D grid to reach the bottom-right corner using BFS graph traversal techniques.
Design a Text Editor
Design a text editor that supports text manipulation and cursor navigation operations efficiently with linked-list-based…
Match Substring After Replacement
Determine if a target substring can appear in a string after optional character replacements using given mappings effici…
Count Subarrays With Score Less Than K
Count all non-empty subarrays whose score, defined as sum times length, is strictly less than a given integer k efficien…
Naming a Company
The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…
Selling Pieces of Wood
Maximize your profit by cutting a wooden piece into smaller parts based on given prices and dimensions.
Number of Distinct Roll Sequences
Calculate the number of distinct sequences of dice rolls based on specific conditions using dynamic programming.
Maximum Score Of Spliced Array
Maximize the score of two arrays by splicing and swapping a subarray using dynamic programming.
Minimum Score After Removals on a Tree
Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.
Number of Increasing Paths in a Grid
Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…
Subarray With Elements Greater Than Varying Threshold
Find the size of a subarray with all elements greater than threshold divided by length using stack-based state managemen…
Count the Number of Ideal Arrays
This problem involves counting the number of ideal arrays of a given length under certain conditions using state transit…
Minimum Deletions to Make Array Divisible
Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.
Shortest Impossible Sequence of Rolls
Find the shortest subsequence that cannot be formed from a sequence of dice rolls, with efficient array scanning and has…
Number of Excellent Pairs
Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…
Longest Cycle in a Graph
The problem asks to find the longest cycle in a directed graph with specific edge constraints.
Minimum Replacements to Sort the Array
Minimize the number of operations to make the array sorted in non-decreasing order by replacing elements with sums of tw…
Count Special Integers
Count the number of special integers in the interval [1, n] where digits of each integer are distinct.
Maximum Segment Sum After Removals
Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…
Find the K-Sum of an Array
Find the K-Sum of an Array requires computing the kth largest subsequence sum in an array using sorting and heap techniq…
Build a Matrix With Conditions
Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…
Maximum Number of Robots Within Budget
Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…
Meeting Rooms III
Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.
Longest Increasing Subsequence II
Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…
Minimum Money Required Before Transactions
Find the minimum money required to complete all transactions in any order while considering cost and cashback.
Sum of Prefix Scores of Strings
The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …
Number of Good Paths
Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.
Number of Pairs Satisfying Inequality
Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.
Maximum Deletions on a String
Find the maximum number of deletions on a string using state transition dynamic programming and rolling hash techniques …
Paths in Matrix Whose Sum Is Divisible by K
Compute all paths in a matrix where the sum of elements is divisible by k using state transition dynamic programming eff…
Create Components With Same Value
Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.
Count Subarrays With Fixed Bounds
Count all subarrays where the minimum and maximum match given bounds using efficient sliding window tracking techniques.
Minimum Cost to Make Array Equal
Find the minimum cost to make all elements of an array equal by using binary search over valid answers.
Minimum Number of Operations to Make Arrays Similar
Determine the minimum operations to make two arrays similar by adjusting pairs while respecting element frequencies and …
Next Greater Element IV
Find the second greater integer for each element in an array using binary search and monotonic stack techniques.
Height of Binary Tree After Subtree Removal Queries
Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…
Minimum Total Distance Traveled
Optimize the total distance traveled by robots to factories using dynamic programming, sorting, and state transitions.
Split Message Based on Limit
Split Message Based on Limit requires dividing a string into parts with length constraints using a calculated suffix pat…
Maximum Number of Non-overlapping Palindrome Substrings
Find the maximum number of non-overlapping palindromic substrings of at least length k in a string using dynamic program…
Number of Beautiful Partitions
The problem involves finding the number of beautiful partitions in a string with dynamic programming and state transitio…
Count Palindromic Subsequences
Count the number of palindromic subsequences of length 5 in a given string of digits.
Count Subarrays With Median K
Count the number of subarrays in a given array with median equal to a specified value k.
Divide Nodes Into the Maximum Number of Groups
Determine the maximum number of groups nodes can form in a graph using depth-first traversal without violating edge conn…
Minimum Total Cost to Make Arrays Unequal
Calculate the minimum cost to rearrange nums1 so that no element matches nums2 using optimal swaps and hash counting.
Maximum Number of Points From Grid Queries
Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.
Add Edges to Make Degrees of All Nodes Even
Determine if it's possible to add at most two edges to make all node degrees even in an undirected graph.
Cycle Length Queries in a Tree
Solve the problem of determining cycle lengths in a binary tree with added edges through queries.
Count Anagrams
Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.
Number of Great Partitions
Calculate the number of great partitions of an array using state transition dynamic programming with careful sum constra…
Maximize the Minimum Powered City
Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…
Time to Cross a Bridge
Time to Cross a Bridge involves simulating worker movements using arrays and heaps to determine when the last worker cro…
Difference Between Maximum and Minimum Price Sum
Compute the maximum difference between any path price sum in a tree using binary-tree traversal and state tracking effic…
Check if Point Is Reachable
Determine if a target point is reachable from (1,1) using math-based moves following number theory rules efficiently.
Minimum Cost to Split an Array
Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…
Put Marbles in Bags
The "Put Marbles in Bags" problem challenges you to distribute marbles into bags for maximum score difference using gree…
Count Increasing Quadruplets
Given a permutation of numbers, count the number of increasing quadruplets using dynamic programming.
Rearranging Fruits
Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…
Subsequence With the Minimum Score
Find the minimum score of a string by removing characters from t while maintaining subsequence validity with s.
Handling Sum Queries After Update
Solve the Handling Sum Queries After Update problem using arrays and segment trees with lazy propagation for efficiency.
Find the String with LCP
Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.
Minimum Time to Visit a Cell In a Grid
Compute the fastest path in a grid where each cell has a minimum time requirement using BFS and priority queue technique…
Count Number of Possible Root Nodes
Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.
Split the Array to Make Coprime Products
Find the smallest index to split an array so that the products of two parts are coprime using array scanning and hash lo…
Number of Ways to Earn Points
Find the number of ways to earn exactly target points using multiple types of exam questions with distinct marks.
Minimum Time to Complete All Tasks
Determine the minimum active time for a computer to complete all scheduled tasks within their specific time windows effi…
Collect Coins in a Tree
The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…
Shortest Cycle in a Graph
Find the shortest cycle in a bi-directional graph using BFS for optimal traversal.
Minimum Reverse Operations
Find the minimum number of operations to move a 1 in an array from a given start position to other positions, considerin…
Minimum Number of Visited Cells in a Grid
Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…
Memoize II
Implementing a memoized function ensures that identical inputs avoid redundant calls, boosting efficiency and performanc…
Design Graph With Shortest Path Calculator
Implement a dynamic weighted directed graph with efficient shortest path queries and edge additions in real time.
Minimize the Total Price of the Trips
Calculate the minimum total cost of multiple trips on a tree by selectively halving node prices using DFS frequency coun…
Design Cancellable Function
Master designing cancellable functions with generators, handling promise flow, cancellation, and error propagation effec…
Make Array Empty
Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.
Lexicographically Smallest Beautiful String
Find the lexicographically smallest beautiful string larger than the given string using greedy choice and invariant vali…
Power of Heroes
Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…
Modify Graph Edge Weights
Modify Graph Edge Weights is a graph problem where you adjust edge weights to match a target shortest path distance.
Greatest Common Divisor Traversal
Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.
Maximum Strictly Increasing Cells in a Matrix
Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…
Count of Integers
Count of Integers challenges you to find the number of integers with a digit sum between a given range using dynamic pro…
Find a Good Subset of the Matrix
Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…
Maximum Sum Queries
Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…
Painting the Walls
Compute the minimum cost to paint all walls using a paid and free painter with state transition dynamic programming.
Robot Collisions
Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.
Sum of Imbalance Numbers of All Subarrays
Learn how to compute the total imbalance across all subarrays by updating gap counts as each subarray expands.
Length of the Longest Valid Substring
This problem asks for the longest valid substring of a word that doesn't contain any substrings from a forbidden list.
Maximum Number of Groups With Increasing Length
Maximize the number of groups that can be formed with given usage limits, leveraging binary search for optimal solutions…
Count Paths That Can Form a Palindrome in a Tree
This problem asks you to count all node pairs in a tree whose path characters can be rearranged into a palindrome using …
Count Stepping Numbers in Range
Count the stepping numbers in a range using dynamic programming with state transitions between digits.
Minimum Time to Make Array Sum At Most x
Calculate the minimum seconds to reduce the array sum to at most x using optimal single-time reductions per index effici…
Maximum Elegance of a K-Length Subsequence
Maximize elegance of a k-length subsequence from a list of items with profits and categories.
Apply Operations to Maximize Score
Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.
Number of Beautiful Integers in the Range
Count all integers in a given range that have equal even and odd digits and are divisible by k using DP.
Minimum Operations to Form Subsequence With Target Sum
The problem requires finding the minimum number of operations to form a subsequence summing to a target using powers of …
Maximize Value of Function in a Ball Passing Game
Maximize the total score in a ball-passing game by selecting the best starting player using state transition dynamic pro…
Count K-Subsequences of a String With Maximum Beauty
Determine the number of k-length unique subsequences in a string that maximize the sum of character frequencies efficien…
Minimum Edge Weight Equilibrium Queries in a Tree
Find the minimum number of operations to equalize edge weights in a tree between given pairs of nodes.
String Transformation
Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.
Minimum Edge Reversals So Every Node Is Reachable
This problem requires solving a graph traversal with edge reversals to ensure every node is reachable in a tree-like str…
Maximum Element-Sum of a Complete Subset of Indices
Given a 1-indexed array, select a subset where indices' product is a perfect square, then return the maximum sum.
Count Valid Paths in a Tree
Count Valid Paths in a Tree involves finding paths with exactly one prime number in a tree of n nodes.
Maximum Number of K-Divisible Components
Determine the maximum number of connected components in a tree where each component sum is divisible by k using DFS.
Count Visited Nodes in a Directed Graph
Count Visited Nodes in a Directed Graph uses dynamic programming to solve graph traversal and node visitation counting e…
Apply Operations on Array to Maximize Sum of Squares
Maximizing the sum of squares in an array through bitwise operations on selected elements.
Count of Sub-Multisets With Bounded Sum
This problem asks you to count the number of sub-multisets within a given array that have a sum in a specified range.
Minimum Changes to Make K Semi-palindromes
Minimize the number of letter changes to partition a string into k semi-palindromes using dynamic programming and two po…
Subarrays Distinct Element Sum of Squares II
Compute the sum of squares of distinct elements in all subarrays using state transition dynamic programming efficiently.
Maximum Points After Collecting Coins From All Nodes
Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.
Maximum Balanced Subsequence Sum
Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…
Maximum Spending After Buying Items
Maximize spending by carefully choosing the right items across multiple shops over m * n days.
Maximum Strong Pair XOR II
Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.
Find Building Where Alice and Bob Can Meet
Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.
Find Maximum Non-decreasing Array Length
Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…
Count Beautiful Substrings II
Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.
Count Complete Substrings
Count Complete Substrings involves finding substrings where each character appears exactly k times with constraints on a…
Count the Number of Infection Sequences
Calculate all valid infection sequences in a line by using array positions and combinatorial math efficiently for n peop…
Number of Possible Sets of Closing Branches
Calculate all valid sets of branch closures while keeping remaining branches within maxDistance using bitmask and graph …
Count the Number of Good Partitions
Calculate how many ways to partition an array into contiguous subarrays where no number repeats across segments using ha…
Apply Operations to Maximize Frequency Score
Maximize the frequency score by applying up to k operations on a sorted array using binary search over valid answer spac…
Count the Number of Incremovable Subarrays II
Count the number of incremovable subarrays where removal of the subarray results in a strictly increasing array.
Find Number of Coins to Place in Tree Nodes
Determine the exact number of coins to place on each tree node using subtree cost products and DFS tracking.
Minimum Cost to Convert String II
Compute the minimum cost to transform source into target using substring replacements with given costs efficiently using…
Palindrome Rearrangement Queries
Given a string and queries, check if rearranging specified substrings can make the string a palindrome.
Count the Number of Powerful Integers
Count the number of powerful integers in a given range by applying state transition dynamic programming with constraints…
Maximize the Number of Partitions After Operations
Maximizing the number of partitions in a string after changing one character and applying partitioning operations using …
Find Beautiful Indices in the Given Array II
Find Beautiful Indices in the Given Array II challenges you to use binary search and string matching techniques.
Divide an Array Into Subarrays With Minimum Cost II
This problem asks to divide an array into subarrays with a minimal cost and certain constraints on subarray positions.
Count the Number of Houses at a Certain Distance II
Count the Number of Houses at a Certain Distance II is a graph problem that requires efficient pair counting with an add…
Minimize OR of Remaining Elements Using Operations
Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.
Find the Number of Ways to Place People II
Calculate all valid placements of people on a 2D grid ensuring Alice can fence herself with Bob without enclosing others…
Minimum Time to Revert Word to Initial State II
The problem asks to calculate the minimum time required to revert a string to its initial state using specific operation…
Number of Subarrays That Match a Pattern II
Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.
Maximize Consecutive Elements in an Array After Modification
Solve Maximize Consecutive Elements in an Array After Modification by sorting and using state transition DP on value and…
Count Prefix and Suffix Pairs II
Count the number of index pairs in a string array where one word is both a prefix and suffix of another using array and …
Earliest Second to Mark Indices II
This problem asks to determine the earliest second at which all indices in an array can be marked using a sequence of op…
Find the Maximum Sum of Node Values
Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…
Distribute Elements Into Two Arrays II
Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…
Maximum Strength of K Disjoint Subarrays
Solve Maximum Strength of K Disjoint Subarrays with dynamic programming that tracks segment state, sign changes, and wei…
Find the Sum of the Power of All Subsequences
Find the sum of the power of all subsequences of an integer array where their sum equals a given number.
Minimum Moves to Pick K Ones
Find the minimum number of moves to pick exactly k ones from a binary array, considering a constraint on changes.
Longest Common Suffix Queries
Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…
Find the Sum of Subsequence Powers
Compute the sum of powers for all subsequences of length k using state transition dynamic programming efficiently.
Minimize Manhattan Distances
Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.
Minimum Cost Walk in Weighted Graph
Find the minimum cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…
Find the Number of Subarrays Where Boundary Elements Are Maximum
Count the subarrays where the first and last elements are the largest in the subarray, utilizing binary search over vali…
Kth Smallest Amount With Single Denomination Combination
Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…
Minimum Sum of Values by Dividing Array
Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.
Find Edges in Shortest Paths
Use two Dijkstra runs to mark exactly which edges can appear on at least one shortest path from 0 to n - 1.
Find All Possible Stable Binary Arrays II
Compute the number of stable binary arrays using state transition dynamic programming with exact zero, one, and limit co…
Find the Median of the Uniqueness Array
Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…
Minimum Cost to Equalize Array
Compute the minimum cost to make all elements equal using selective operations guided by greedy choices and invariant ch…
Find Products of Elements of Big Array
Solve queries on a massive array of powers of two using binary search to efficiently compute modular products of subarra…
Find the Minimum Cost Array Permutation
Determine the lexicographically smallest permutation of nums that minimizes a cyclic score using state transition DP tec…
Find Number of Ways to Reach the K-th Stair
Determine the total number of ways to reach the k-th stair using a state transition dynamic programming approach with co…
Block Placement Queries
Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…
Maximum Sum of Subsequence With Non-adjacent Elements
Compute the maximum sum of a subsequence where no two adjacent elements are selected after each array update efficiently…
Find Subarray With Bitwise OR Closest to K
Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.
Find the Maximum Length of a Good Subsequence II
Determine the maximum length of a good subsequence in an integer array using array scanning and hash lookup efficiently.
Maximum Total Reward Using Operations II
Maximize your total reward using dynamic programming with state transitions in this challenging problem involving array …
Peaks in Array
Determine peaks in a dynamic integer array using efficient Binary Indexed Tree updates and range queries for fast result…
Count the Number of Inversions
Count the number of valid permutations satisfying inversion constraints using state transition dynamic programming.
Find the Minimum Area to Cover All Ones II
Find the minimum area to cover all 1's in a 2D binary grid using three non-overlapping rectangles.
Find Minimum Diameter After Merging Two Trees
Calculate the minimum diameter after merging two trees by strategically connecting nodes to minimize the longest path in…
Number of Subarrays With AND Value of K
The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…
Construct String with Minimum Cost
This problem asks you to construct a target string using given words at minimal cost using dynamic programming technique…
Minimum Cost for Cutting Cake II
Solve Minimum Cost for Cutting Cake II by choosing optimal cuts using a greedy strategy while tracking cost increments p…
Maximum Score From Grid Operations
Maximize your score by choosing the optimal sequence of column operations on a grid using dynamic programming transition…
Minimum Operations to Make Array Equal to Target
This problem requires calculating the minimum number of operations to transform one array into another using state trans…
Check if the Rectangle Corner Is Reachable
Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.
Time Taken to Mark All Nodes
Calculate the time taken to mark all nodes in a tree, starting from any node with time t=0.
Shortest Distance After Road Addition Queries II
The problem involves calculating the shortest path from city 0 to city n-1 after each road addition, leveraging greedy c…
Alternating Groups III
Solve Alternating Groups III using array manipulation and a binary indexed tree to track maximal alternating sequences e…
Find the Count of Monotonic Pairs I
Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.
Find the Count of Monotonic Pairs II
This problem involves finding the count of monotonic pairs in an array using dynamic programming and combinatorics techn…
Maximum Value Sum by Placing Three Rooks I
Maximize the value sum by placing three rooks on a chessboard while ensuring they do not attack each other.
Maximum Value Sum by Placing Three Rooks II
Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.
Find the Largest Palindrome Divisible by K
Compute the largest n-digit integer divisible by k that forms a palindrome using state transition dynamic programming te…
Count Substrings That Satisfy K-Constraint II
Count Substrings That Satisfy K-Constraint II requires finding valid substrings in a binary string based on a k-constrai…
Final Array State After K Multiplication Operations II
Optimize the final state of an array after performing k multiplication operations with priority queues.
Count Almost Equal Pairs II
Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.
Find the Count of Good Integers
Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.
Minimum Amount of Damage Dealt to Bob
Minimize the total damage dealt to Bob using power to eliminate enemies efficiently with greedy approach.
Select Cells in Grid With Maximum Score
Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.
Maximum XOR Score Subarray Queries
Solve the Maximum XOR Score Subarray Queries problem using state transition dynamic programming for optimal subarray com…
Maximum Number of Moves to Kill All Pawns
Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…
Find the Maximum Sequence Value of Array
Determine the maximum value of a subsequence in an integer array using state transition dynamic programming and bit oper…
Length of the Longest Increasing Path
Determine the maximum length of an increasing path in a 2D array using binary search over potential path lengths efficie…
Minimum Number of Valid Strings to Form Target II
Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…
Count Substrings That Can Be Rearranged to Contain a String II
Count Substrings That Can Be Rearranged to Contain a String II involves identifying valid substrings with a sliding wind…
Find the Occurrence of First Almost Equal Substring
Locate the first substring in s that is almost equal to pattern by allowing at most one character mismatch efficiently.
Find the K-th Character in String Game II
Find the K-th character in a string game using bit manipulation and recursion, optimizing performance for large k values…
Construct 2D Grid Matching Graph Layout
This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.
Sorted GCD Pair Queries
Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…
Find the Number of Possible Ways for an Event
Given n performers, x stages, and y scores, calculate the number of possible ways to assign performers and score bands.
Count The Number of Winning Sequences
Count The Number of Winning Sequences is a dynamic programming challenge involving state transitions based on Alice’s cr…
Find X-Sum of All K-Long Subarrays II
Calculate the x-sum for every k-length subarray using efficient array scanning and hash-based counting techniques.
Check if DFS Strings Are Palindromes
Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…
Find the Original Typed String II
Calculate how many potential original strings Alice might have intended to type, considering her clumsy typing behavior.
Find the Number of Subsequences With Equal GCD
Count all pairs of non-empty subsequences in an integer array whose elements share the same greatest common divisor effi…
Total Characters in String After Transformations II
Calculate the length of a string after repeated transformations using state transition dynamic programming for large t v…
Count Number of Balanced Permutations
Determine how many distinct permutations of a digit string are balanced using state transition dynamic programming effic…
Maximum Frequency of an Element After Performing Operations II
Determine the maximum frequency of any element after performing limited operations using binary search and sliding windo…
Smallest Divisible Digit Product II
Find the smallest zero-free number at least as large as num whose digits multiply to a product divisible by t using care…
Sum of Good Subsequences
Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.
Count K-Reducible Numbers Less Than N
This problem challenges you to count the K-reducible numbers less than a given binary integer using dynamic programming.
Minimize the Maximum Adjacent Element Difference
Minimize the maximum adjacent element difference by filling missing values with two chosen numbers.
Find the Maximum Number of Fruits Collected
Maximize the number of fruits collected by three children navigating a grid dungeon with dynamic programming.
Maximize Sum of Weights after Edge Removals
Maximize the sum of edge weights in a tree after removals, using dynamic programming and tree traversal techniques.
Maximize the Number of Target Nodes After Connecting Trees II
Maximize the number of target nodes after connecting two trees by analyzing their structure and target relationships.
Count Connected Components in LCM Graph
Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…
Maximum Area Rectangle With Point Constraints II
Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…
Minimum Operations to Make Character Frequencies Equal
This Hard problem asks to transform a string so all character frequencies match using minimal deletions, leveraging dyna…
Subsequences with a Unique Middle Mode I
Count subsequences of size 5 with a unique middle mode in an integer array using hash table and combinatorics.
Smallest Substring With Identical Characters I
Minimize the length of the longest substring with identical characters after at most numOps changes in a binary string.
Smallest Substring With Identical Characters II
Find the minimal length of a substring with identical characters using binary search and controlled character flips effi…
Count the Number of Arrays with K Matching Adjacent Elements
Count the number of valid arrays with exactly k adjacent elements that are equal, using math and combinatorics technique…
Maximize Subarray Sum After Removing All Occurrences of One Element
Maximize Subarray Sum After Removing All Occurrences of One Element involves finding the optimal subarray sum with one a…
Maximum Score of Non-overlapping Intervals
Maximize the score of up to 4 non-overlapping intervals, considering their weight and ensuring no overlap between chosen…
Count Non-Decreasing Subarrays After K Operations
This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.
Longest Special Path
Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.
Manhattan Distances of All Arrangements of Pieces
This problem challenges you to calculate Manhattan distances in all valid arrangements of identical pieces on a grid.
Maximum and Minimum Sums of at Most Size K Subarrays
Compute the sum of maximum and minimum values in all subarrays up to size k using efficient stack-based state management…
Frequencies of Shortest Supersequences
Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …
Minimum Cost Good Caption
Solve Minimum Cost Good Caption with dynamic programming that builds minimum edit cost while enforcing character runs of…
Minimum Increments for Target Multiples in an Array
This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…
Maximum Difference Between Even and Odd Frequency II
Find the maximum difference between even and odd character frequencies in substrings using sliding window updates effici…
Count Substrings Divisible By Last Digit
Count the number of substrings in a string divisible by their last non-zero digit using dynamic programming.
Maximize the Minimum Game Score
Maximizing the minimum score after at most m moves, leveraging binary search and greedy strategies over an array of scor…
Separate Squares II
Separate Squares II requires finding the minimum y-coordinate such that squares' areas are split evenly above and below …
Shortest Matching Substring
Find the shortest substring in a string that matches a pattern with exactly two wildcards efficiently using binary searc…
Length of Longest V-Shaped Diagonal Segment
Compute the maximum length of a V-shaped diagonal segment in a 2D integer matrix using state transition dynamic programm…
Check If Digits Are Equal in String After Operations II
Determine if repeated digit-sum operations on a numeric string reduce it to two equal digits using math and string techn…
Maximize the Distance Between Points on a Square
Select k points on a square boundary to maximize minimum Manhattan distance using binary search and greedy placement str…
Permutations IV
Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…
Lexicographically Smallest Generated String
Generate the lexicographically smallest string by merging str1 and str2 using a greedy approach with invariant checks.
Maximize Subarrays After Removing One Conflicting Pair
Maximize the count of subarrays after removing one conflicting pair using array traversal and segment tree logic efficie…
Longest Common Prefix of K Strings After Removal
Find the longest common prefix length of k strings after removing an element in the array.
Longest Special Path II
Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…
Count Beautiful Numbers
Count Beautiful Numbers using state transition dynamic programming to efficiently calculate valid numbers in a given ran…
Minimum Operations to Make Array Elements Zero
Minimize operations to reduce array elements to zero, focusing on array manipulation, math, and bit operations for effic…
Minimum Cost to Divide Array Into Subarrays
Optimize array splits with dynamic programming to minimize costs for the Minimum Cost to Divide Array Into Subarrays pro…
Maximize Active Section with Trade II
Maximize the number of active sections in a binary string with at most one trade.
Longest Palindrome After Substring Concatenation II
Compute the longest palindrome by concatenating substrings from two strings using state transition dynamic programming e…
Minimum Operations to Make Elements Within K Subarrays Equal
Compute the minimum operations to ensure at least k non-overlapping subarrays of size x have all equal elements efficien…
Maximum Product of Subsequences With an Alternating Sum Equal to K
Find the maximum product of a subsequence in an array with an alternating sum equal to a given target.
Minimum Pair Removal to Sort Array II
The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.
Shortest Path in a Weighted Tree
Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.
Smallest Palindromic Rearrangement II
Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.
Count Numbers with Non-Decreasing Digits
Count all integers between l and r whose digits never decrease in base b using state transition dynamic programming effi…
Find X Value of Array II
The "Find X Value of Array II" problem requires calculating the number of ways to remove a suffix from an array such tha…
Maximum Profit from Valid Topological Order in DAG
Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…
Concatenated Divisibility
Find the lexicographically smallest permutation of numbers whose concatenation is divisible by k using state transition …
Path Existence Queries in a Graph II
Solve path existence queries in a graph using binary search on the answer space, focusing on sorted nodes and maximum di…
Merge Operations for Minimum Travel Time
Minimize the total travel time by merging road signs, using dynamic programming to manage state transitions efficiently.
Find Sum of Array Product of Magical Sequences
Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…
Subtree Inversion Sum
This problem involves calculating the maximum possible subtree inversion sum with dynamic programming and binary-tree tr…
Maximum Sum of Edge Values in a Graph
Maximize the sum of edge values in a connected graph by assigning unique node values and optimizing edge products.
Equal Sum Grid Partition II
Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.
Minimum Weighted Subgraph With the Required Paths II
Solve the Minimum Weighted Subgraph With the Required Paths II problem by leveraging binary-tree traversal and efficient…
Number of Ways to Assign Edge Weights II
This problem involves assigning edge weights in a tree and calculating the cost of paths based on these weights.
Maximum Profit from Trading Stocks with Discounts
Solve the Maximum Profit from Trading Stocks with Discounts problem using binary-tree traversal and dynamic state tracki…
Lexicographically Smallest String After Adjacent Removals
Find the lexicographically smallest string by repeatedly removing adjacent characters optimally using dynamic programmin…
Maximize Count of Distinct Primes After Split
Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…
Maximize Subarray GCD Score
Maximize Subarray GCD Score focuses on maximizing a subarray's score by using at most k doubling operations on an array …
Maximum Good Subtree Score
Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…
Minimum Steps to Convert String with Operations
Transform word1 into word2 using minimal operations on substrings with a dynamic programming state transition approach.
Find Weighted Median Node in Tree
Given a weighted tree and queries, find the weighted median node for each path between two nodes using binary-tree trave…
Kth Smallest Path XOR Sum
This problem involves finding the kth smallest distinct XOR sum for nodes in a subtree of a tree structure using binary-…
Minimum Time to Transport All Individuals
Find the minimum time to transport individuals across a river with dynamic environmental conditions and boat capacity.
Maximize Spanning Tree Stability with Upgrades
Maximizing the stability of a spanning tree with upgrades requires careful optimization of edge strengths using binary s…
Minimum Stability Factor of Array
The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…
Minimum Moves to Reach Target in Grid
Find the minimum number of moves to reach a target point from a start point on a 2D grid with a math-driven solution.
Process String with Special Operations II
Solve the problem of processing strings with special operations like '*' and '#' by simulating the rules left-to-right.
Longest Palindromic Path in Graph
Find the longest path in a graph that forms a palindrome using state transition dynamic programming and bitmask techniqu…
Find Students with Study Spiral Pattern
Solve Find Students with Study Spiral Pattern by validating each student's ordered subject cycle, consistency, and repea…
Network Recovery Pathways
Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.
Number of Integers With Popcount-Depth Equal to K I
Calculate the number of integers in a given range with a specific popcount-depth using state transition dynamic programm…
Number of Integers With Popcount-Depth Equal to K II
This problem challenges you to efficiently calculate the number of integers with popcount-depth equal to K using array a…
Count Number of Trapezoids II
Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…
Partition Array for Maximum XOR and AND
Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.
Threshold Majority Queries
Find the majority element in subarrays that appear at least a threshold number of times, or -1 if none exists.
Trionic Array II
Trionic Array II is a challenging problem involving the sum of contiguous subarrays with special index constraints.
Top Topics In This Track
Guided Practice Path
AI recommends problems by your level and tracks your progress.
Start Guided Patharrow_forward