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.

4

Median of Two Sorted Arrays

Find the median of two sorted arrays using binary search for efficient O(log(min(m, n))) time complexity.

Hard
10

Regular Expression Matching

The Regular Expression Matching problem involves checking if a string matches a pattern using '.' and '*'.

Hard
23

Merge k Sorted Lists

Merge k Sorted Lists requires efficiently combining multiple sorted linked lists into one using pointers and priority qu…

Hard
25

Reverse Nodes in k-Group

Reverse Nodes in k-Group challenges you to reverse segments of a linked list in groups of size k.

Hard
30

Substring with Concatenation of All Words

Find all starting indices of substrings in a string that are concatenations of a given list of words.

Hard
32

Longest Valid Parentheses

Compute the length of the longest well-formed parentheses substring using state transition dynamic programming and stack…

Hard
37

Sudoku Solver

Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.

Hard
41

First Missing Positive

Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…

Hard
42

Trapping Rain Water

Calculate the total trapped rain water using the elevation map array, leveraging dynamic programming and two-pointer pat…

Hard
44

Wildcard Matching

Implement full wildcard pattern matching using '?' and '*' by applying state transition dynamic programming with careful…

Hard
51

N-Queens

Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…

Hard
52

N-Queens II

Solve the N-Queens II problem using backtracking with pruning to efficiently count all valid placements for n queens on …

Hard
60

Permutation Sequence

Find the kth permutation sequence of a set of numbers using math and recursion to efficiently compute the result.

Hard
65

Valid Number

Determine if a given string represents a valid number using precise string parsing and character validation rules.

Hard
68

Text Justification

Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.

Hard
76

Minimum Window Substring

Find the smallest substring of s containing all characters from t using a sliding window with running state updates for …

Hard
84

Largest Rectangle in Histogram

Find the maximal rectangular area in a histogram using stack-based state management for precise bar tracking and width c…

Hard
85

Maximal Rectangle

Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…

Hard
87

Scramble String

Scramble String is a dynamic programming problem where we determine if one string can be scrambled to form another using…

Hard
115

Distinct Subsequences

Compute the number of distinct subsequences of one string matching another using precise state transition dynamic progra…

Hard
123

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…

Hard
124

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…

Hard
126

Word Ladder II

Find all shortest transformation sequences from beginWord to endWord using a dictionary, leveraging backtracking search …

Hard
127

Word Ladder

Find the shortest transformation sequence from a start word to an end word, with each word in the sequence differing by …

Hard
132

Palindrome Partitioning II

Determine the minimum cuts required to partition a string into all palindromic substrings using dynamic programming tech…

Hard
135

Candy

The Candy problem is a greedy algorithm challenge where you need to minimize candy distribution while satisfying certain…

Hard
140

Word Break II

Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.

Hard
149

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.

Hard
154

Find Minimum in Rotated Sorted Array II

Find the minimum in a rotated sorted array with possible duplicates using binary search.

Hard
174

Dungeon Game

Calculate the minimum initial health the knight needs to survive the dungeon using state transition dynamic programming …

Hard
188

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…

Hard
212

Word Search II

Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.

Hard
214

Shortest Palindrome

The Shortest Palindrome problem asks to transform a string into a palindrome by adding characters at the beginning, with…

Hard
218

The Skyline Problem

The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …

Hard
220

Contains Duplicate III

The problem involves finding a pair of indices in an array where the index and value differences are within given limits…

Hard
224

Basic Calculator

Implement a basic calculator to evaluate mathematical expressions, ensuring correct evaluation with stack-based manageme…

Hard
233

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…

Hard
239

Sliding Window Maximum

Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…

Hard
273

Integer to English Words

Convert a given integer to its English words representation using mathematical logic and string manipulation.

Hard
282

Expression Add Operators

Expression Add Operators is solved with backtracking that builds multi-digit operands and tracks multiplication preceden…

Hard
295

Find Median from Data Stream

Implement a MedianFinder class that supports adding numbers and finding the median from a data stream.

Hard
297

Serialize and Deserialize Binary Tree

This problem asks to serialize and deserialize a binary tree, requiring an efficient approach to handle traversal and st…

Hard
301

Remove Invalid Parentheses

Remove the minimum number of invalid parentheses to generate all possible valid strings efficiently using backtracking a…

Hard
312

Burst Balloons

Burst Balloons is a hard dynamic programming problem requiring careful state transitions to maximize coins collected eff…

Hard
315

Count of Smaller Numbers After Self

Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.

Hard
321

Create Maximum Number

Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.

Hard
327

Count of Range Sum

Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…

Hard
329

Longest Increasing Path in a Matrix

Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.

Hard
330

Patching Array

Patching Array requires adding the minimum numbers to cover all sums from 1 to n using greedy choices and invariant chec…

Hard
332

Reconstruct Itinerary

Reconstruct Itinerary requires building a valid travel route using all tickets once, starting from JFK with lexical orde…

Hard
335

Self Crossing

Determine if a path defined by sequential distances on a 2D plane crosses itself using array and math reasoning.

Hard
336

Palindrome Pairs

Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.

Hard
352

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…

Hard
354

Russian Doll Envelopes

Russian Doll Envelopes is a dynamic programming problem that involves finding the longest chain of envelopes that can be…

Hard
363

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…

Hard
381

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…

Hard
391

Perfect Rectangle

Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…

Hard
403

Frog Jump

Determine if a frog can cross a river using jumps constrained by previous step sizes in a dynamic programming state tran…

Hard
407

Trapping Rain Water II

Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.

Hard
410

Split Array Largest Sum

Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…

Hard
420

Strong Password Checker

The Strong Password Checker problem challenges you to optimize password strength while minimizing steps using greedy alg…

Hard
432

All O`one Data Structure

Implement a data structure that tracks string counts and retrieves max or min keys efficiently in constant time.

Hard
440

K-th Smallest in Lexicographical Order

Find the k-th lexicographically smallest integer in a range using a Trie-based approach.

Hard
446

Arithmetic Slices II - Subsequence

Count all arithmetic subsequences in an array using dynamic programming with precise state transitions for correctness.

Hard
458

Poor Pigs

Find the minimum number of pigs required to determine the poisonous bucket within a set time using state transition dyna…

Hard
460

LFU Cache

Implement an LFU Cache using linked-list pointer manipulation with constant-time get and put operations for interview sc…

Hard
466

Count The Repetitions

This problem requires counting how many times a repeated string s2 fits as a subsequence within a repeated string s1 usi…

Hard
472

Concatenated Words

Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …

Hard
479

Largest Palindrome Product

Find the largest palindromic number from the product of two n-digit integers using math and enumeration efficiently.

Hard
480

Sliding Window Median

Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…

Hard
483

Smallest Good Base

Find the smallest good base of an integer n using binary search over the valid answer space.

Hard
488

Zuma Game

The Zuma Game involves clearing balls from the board using a limited hand, applying dynamic programming and state transi…

Hard
493

Reverse Pairs

Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.

Hard
502

IPO

Maximize total capital by selecting up to k projects, based on initial capital and project profits using a greedy strate…

Hard
514

Freedom Trail

Determine the minimum rotations and button presses to spell a keyword on a circular dial using state transition dynamic …

Hard
517

Super Washing Machines

Calculate the minimum moves to balance dresses across washing machines using a greedy strategy and invariant validation …

Hard
546

Remove Boxes

Maximize points by strategically removing contiguous same-colored boxes using state transition dynamic programming and m…

Hard
552

Student Attendance Record II

The Student Attendance Record II problem explores counting valid student attendance sequences using dynamic programming …

Hard
564

Find the Closest Palindrome

Identify the nearest palindrome to a given integer string, handling ties and large numbers efficiently using math and st…

Hard
587

Erect the Fence

Find the perimeter fence of a garden by determining the outermost trees in a set of given tree coordinates.

Hard
591

Tag Validator

The Tag Validator problem involves validating a code snippet by parsing through tags using a stack-based state managemen…

Hard
600

Non-negative Integers without Consecutive Ones

Count non-negative integers up to n without consecutive ones in their binary representation using dynamic programming.

Hard
629

K Inverse Pairs Array

The K Inverse Pairs Array problem focuses on counting arrays with exactly k inverse pairs using dynamic programming.

Hard
630

Course Schedule III

Solve the 'Course Schedule III' problem with a greedy approach involving course selection and validation of constraints.

Hard
632

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…

Hard
639

Decode Ways II

Decode Ways II is a challenging dynamic programming problem that involves decoding messages with digits and wildcard cha…

Hard
664

Strange Printer

Calculate the minimum turns a strange printer needs to print any string using state transition dynamic programming effic…

Hard
668

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.

Hard
675

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…

Hard
679

24 Game

Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…

Hard
685

Redundant Connection II

Find and remove the redundant connection in a directed graph that was originally a rooted tree.

Hard
689

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.

Hard
691

Stickers to Spell Word

Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…

Hard
699

Falling Squares

Solve Falling Squares by efficiently computing maximum stack heights using arrays with segment tree optimization techniq…

Hard
710

Random Pick with Blacklist

Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…

Hard
715

Range Module

Design a RangeModule to track and query half-open intervals using segment trees or ordered sets.

Hard
719

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…

Hard
726

Number of Atoms

Compute the exact count of each atom in a chemical formula using stack-based state management and hashing techniques eff…

Hard
730

Count Different Palindromic Subsequences

Count Different Palindromic Subsequences leverages dynamic programming to count non-empty palindromic subsequences in a …

Hard
732

My Calendar III

Implement My Calendar III to track maximum overlapping events efficiently using binary search and segment tree technique…

Hard
736

Parse Lisp Expression

Parse Lisp expressions using stack-based state management to evaluate variables and operations.

Hard
741

Cherry Pickup

Maximize cherries collected on a grid, employing state transition dynamic programming with careful navigation across obs…

Hard
745

Prefix and Suffix Search

Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.

Hard
749

Contain Virus

Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…

Hard
753

Cracking the Safe

The Cracking the Safe problem involves finding the shortest password sequence to unlock a safe using graph traversal and…

Hard
757

Set Intersection Size At Least Two

Solve the Set Intersection Size At Least Two problem using a greedy approach and invariant validation.

Hard
761

Special Binary String

Solve the Special Binary String problem using string manipulation and recursion, optimizing lexicographical order.

Hard
765

Couples Holding Hands

This problem requires arranging couples sitting apart in a row with the minimum number of swaps using graph traversal an…

Hard
768

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 …

Hard
770

Basic Calculator IV

Simplify mathematical expressions using stack-based state management, handling variables, operators, and polynomial term…

Hard
773

Sliding Puzzle

Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …

Hard
778

Swim in Rising Water

Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.

Hard
780

Reaching Points

Determine whether it is possible to reach a target point from a start point using repeated additive moves following stri…

Hard
782

Transform to Chessboard

Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.

Hard
793

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.

Hard
798

Smallest Rotation with Highest Score

Find the smallest rotation index with the highest score using array and prefix sum techniques.

Hard
801

Minimum Swaps To Make Sequences Increasing

This problem involves finding the minimum number of swaps needed to make two sequences strictly increasing using dynamic…

Hard
803

Bricks Falling When Hit

Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.

Hard
805

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…

Hard
810

Chalkboard XOR Game

The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…

Hard
815

Bus Routes

Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.

Hard
818

Race Car

Race Car is a dynamic programming problem where the goal is to find the shortest sequence of instructions to reach a tar…

Hard
827

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…

Hard
828

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.

Hard
829

Consecutive Numbers Sum

Find the number of ways to express a number as the sum of consecutive positive integers.

Hard
834

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 …

Hard
839

Similar String Groups

Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…

Hard
843

Guess the Word

Master the Guess the Word problem by applying array manipulation, match-counting math, and strategic interactive guessin…

Hard
847

Shortest Path Visiting All Nodes

Solve the Shortest Path Visiting All Nodes problem by exploring dynamic programming, bit manipulation, and breadth-first…

Hard
850

Rectangle Area II

The problem involves calculating the total area covered by multiple rectangles, ensuring overlap is counted only once.

Hard
854

K-Similar Strings

K-Similar Strings involves finding the minimal number of swaps to transform one string into another through character sw…

Hard
857

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…

Hard
862

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.

Hard
864

Shortest Path to Get All Keys

Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.

Hard
871

Minimum Number of Refueling Stops

Determine the minimum number of refueling stops needed to reach a target using dynamic programming and greedy strategies…

Hard
878

Nth Magical Number

Find the nth magical number divisible by a or b, using binary search to efficiently handle large inputs.

Hard
879

Profitable Schemes

Given a group of members and a list of crimes, count the profitable schemes that meet the profit and group constraints.

Hard
882

Reachable Nodes In Subdivided Graph

The Reachable Nodes In Subdivided Graph problem requires efficiently finding the reachable nodes using graph traversal a…

Hard
887

Super Egg Drop

Solve the Super Egg Drop problem using dynamic programming and binary search to minimize the number of moves required to…

Hard
891

Sum of Subsequence Widths

Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.

Hard
895

Maximum Frequency Stack

Design a stack-like data structure to manage elements and handle frequent stack operations, including popping the most f…

Hard
899

Orderly Queue

Given a string and integer k, rearrange characters to achieve the lexicographically smallest string using limited rotati…

Hard
902

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 …

Hard
903

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…

Hard
906

Super Palindromes

Count all super-palindromes in a given numeric range, where each is a palindrome and square of a palindrome.

Hard
913

Cat and Mouse

Determine the outcome of a two-player Cat and Mouse game on a graph using topological ordering and memoized dynamic prog…

Hard
920

Number of Music Playlists

Solve the Number of Music Playlists problem with dynamic programming, focusing on state transitions and combinatorics to…

Hard
924

Minimize Malware Spread

Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.

Hard
927

Three Equal Parts

Divide a binary array into three contiguous parts such that each part represents the same integer value in binary, using…

Hard
928

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.

Hard
936

Stamping The Sequence

Solve Stamping The Sequence with stack-based state management to convert string s to target using stamp efficiently.

Hard
940

Distinct Subsequences II

Find the number of distinct non-empty subsequences of a string using dynamic programming and state transitions.

Hard
943

Find the Shortest Superstring

This problem requires constructing the shortest string containing all input words using state transition dynamic program…

Hard
952

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 …

Hard
956

Tallest Billboard

Solve the Tallest Billboard problem by using dynamic programming to find the maximum equal height for two disjoint rod s…

Hard
960

Delete Columns to Make Sorted III

The problem requires minimizing deletions to ensure all strings are lexicographically sorted. Use dynamic programming fo…

Hard
964

Least Operators to Express Number

Compute the minimum number of arithmetic operators to form a target using repeated x with addition, subtraction, multipl…

Hard
968

Binary Tree Cameras

Determine the minimum number of cameras required to monitor every node in a binary tree using efficient DFS and state tr…

Hard
972

Equal Rational Numbers

Given two rational numbers as strings with possible repeating decimals, determine if they represent the same number.

Hard
975

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…

Hard
980

Unique Paths III

Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…

Hard
982

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…

Hard
987

Vertical Order Traversal of a Binary Tree

Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.

Hard
992

Subarrays with K Different Integers

Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.

Hard
995

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…

Hard
996

Number of Squareful Arrays

Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…

Hard
1000

Minimum Cost to Merge Stones

Minimize the cost to merge stones with k consecutive piles using dynamic programming to achieve the optimal solution.

Hard
1001

Grid Illumination

Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …

Hard
1012

Numbers With Repeated Digits

Solve Numbers With Repeated Digits by counting unique-digit numbers up to n, then subtracting from n using digit DP.

Hard
1028

Recover a Tree From Preorder Traversal

Recover a binary tree from its preorder traversal string by tracking node depth and reconstructing child relationships e…

Hard
1032

Stream of Characters

Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…

Hard
1036

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…

Hard
1044

Longest Duplicate Substring

Find the longest duplicated substring in a string using binary search, sliding window, and rolling hash techniques.

Hard
1074

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…

Hard
1092

Shortest Common Supersequence

Compute the shortest string containing both given strings as subsequences using state transition dynamic programming eff…

Hard
1095

Find in Mountain Array

Find in Mountain Array requires locating a target using binary search over a peak-structured array efficiently in intera…

Hard
1096

Brace Expansion II

Solve Brace Expansion II efficiently by using stack-based state management to generate all unique combinations of nested…

Hard
1106

Parsing A Boolean Expression

Solve the "Parsing A Boolean Expression" problem by evaluating boolean expressions using stack-based state management, r…

Hard
1125

Smallest Sufficient Team

Find the smallest subset of people covering all required skills using bitmask dynamic programming for efficient state tr…

Hard
1147

Longest Chunked Palindrome Decomposition

Solve the "Longest Chunked Palindrome Decomposition" problem by using dynamic programming and string manipulation techni…

Hard
1157

Online Majority Element In Subarray

Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.

Hard
1163

Last Substring in Lexicographical Order

Identify the lexicographically last substring in a string using two-pointer scanning with invariant tracking efficiently…

Hard
1172

Dinner Plate Stacks

Design a system that manages dinner plate stacks using stack-based state management, handling dynamic plate placement an…

Hard
1178

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…

Hard
1187

Make Array Strictly Increasing

Determine the minimum operations to transform arr1 into a strictly increasing sequence using values from arr2 efficientl…

Hard
1192

Critical Connections in a Network

Find critical connections in a network of servers, ensuring efficient traversal using depth-first search and Tarjan's al…

Hard
1203

Sort Items by Groups Respecting Dependencies

Sort items into groups while respecting dependencies using graph indegree tracking and topological ordering patterns eff…

Hard
1206

Design Skiplist

Implement a Skiplist efficiently using linked-list pointer manipulation to support search, add, and erase operations in …

Hard
1210

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.

Hard
1220

Count Vowels Permutation

Count Vowels Permutation requires computing the number of valid vowel strings of length n using state transition dynamic…

Hard
1223

Dice Roll Simulation

Calculate all valid sequences of n dice rolls with consecutive roll constraints using state transition dynamic programmi…

Hard
1224

Maximum Equal Frequency

Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…

Hard
1235

Maximum Profit in Job Scheduling

Compute the maximum profit from non-overlapping jobs using state transition dynamic programming with sorted arrays and b…

Hard
1240

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 …

Hard
1250

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 …

Hard
1255

Maximum Score Words Formed by Letters

Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…

Hard
1263

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…

Hard
1269

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.

Hard
1278

Palindrome Partitioning III

Find the minimal character changes to split a string into k palindromes using precise dynamic programming state transiti…

Hard
1284

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…

Hard
1289

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…

Hard
1293

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.

Hard
1298

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…

Hard
1301

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.

Hard
1307

Verbal Arithmetic Puzzle

Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.

Hard
1312

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…

Hard
1316

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…

Hard
1320

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.

Hard
1326

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…

Hard
1330

Reverse Subarray To Maximize Array Value

Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.

Hard
1335

Minimum Difficulty of a Job Schedule

Schedule jobs into multiple days to minimize the difficulty of the schedule using dynamic programming and state transiti…

Hard
1340

Jump Game V

Jump Game V is a hard dynamic programming problem that focuses on maximizing jumps between indices in an array.

Hard
1345

Jump Game IV

Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…

Hard
1349

Maximum Students Taking Exam

Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…

Hard
1354

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…

Hard
1359

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…

Hard
1363

Largest Multiple of Three

Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…

Hard
1368

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.

Hard
1373

Maximum Sum BST in Binary Tree

Find the maximum sum of values from any Binary Search Tree (BST) subtree in a binary tree.

Hard
1377

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.

Hard
1383

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…

Hard
1388

Pizza With 3n Slices

Maximize your pizza slice sum from a 3n-sized circular array using state transition dynamic programming efficiently.

Hard
1392

Longest Happy Prefix

Find the longest non-empty prefix of a string that also appears as its suffix, optimizing with rolling hash techniques.

Hard
1397

Find All Good Strings

Find all good strings between two given strings without including a specified evil substring using dynamic programming.

Hard
1402

Reducing Dishes

Maximize the sum of like-time coefficients by optimally choosing dishes to prepare in this dynamic programming problem.

Hard
1406

Stone Game III

Stone Game III is a challenging dynamic programming problem based on game theory and state transition logic.

Hard
1411

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.

Hard
1416

Restore The Array

Calculate the number of arrays that can be restored from a string of digits where each number is within [1, k].

Hard
1420

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…

Hard
1425

Constrained Subsequence Sum

Solve the Constrained Subsequence Sum problem using dynamic programming, sliding window, and priority queues to maximize…

Hard
1434

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…

Hard
1439

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.

Hard
1444

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…

Hard
1449

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 …

Hard
1453

Maximum Number of Darts Inside of a Circular Dartboard

Maximize the number of darts on a circular dartboard given dart positions and radius.

Hard
1458

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…

Hard
1463

Cherry Pickup II

Maximize cherry collection in a grid using two robots with careful state transition dynamic programming to optimize path…

Hard
1467

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…

Hard
1473

Paint House III

Solve Paint House III using state transition dynamic programming to minimize painting costs while forming exact neighbor…

Hard
1478

Allocate Mailboxes

Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…

Hard
1483

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.

Hard
1489

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.

Hard
1494

Parallel Courses II

Determine the minimum semesters to complete all courses with prerequisites using state transition dynamic programming an…

Hard
1499

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…

Hard
1505

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…

Hard
1510

Stone Game IV

Stone Game IV requires predicting the winner using state transition dynamic programming with careful consideration of pe…

Hard
1515

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.

Hard
1520

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…

Hard
1521

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.

Hard
1526

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…

Hard
1531

String Compression II

Solve String Compression II with dynamic programming that tracks deletions, run boundaries, and digit-length jumps in co…

Hard
1537

Get the Maximum Score

Find the maximum possible score from two sorted arrays with a dynamic programming approach, leveraging partitioning and …

Hard
1542

Find Longest Awesome Substring

Find the maximum-length awesome substring in a numeric string using hash table and bit manipulation for palindrome poten…

Hard
1547

Minimum Cost to Cut a Stick

Find the minimum cost to cut a stick into segments at specified positions using dynamic programming and sorting.

Hard
1553

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.

Hard
1563

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…

Hard
1568

Minimum Number of Days to Disconnect Island

Find the minimum number of days to disconnect an island in a grid using depth-first search.

Hard
1569

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.

Hard
1575

Count All Possible Routes

This problem requires counting all possible routes between cities using fuel efficiently with state transition dynamic p…

Hard
1579

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.

Hard
1585

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.

Hard
1591

Strange Printer II

Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…

Hard
1595

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.

Hard
1601

Maximum Number of Achievable Transfer Requests

Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.

Hard
1606

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…

Hard
1610

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…

Hard
1611

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…

Hard
1617

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…

Hard
1622

Fancy Sequence

Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…

Hard
1627

Graph Connectivity With Threshold

In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…

Hard
1632

Rank Transform of a Matrix

Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…

Hard
1639

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…

Hard
1643

Kth Smallest Instructions

Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…

Hard
1649

Create Sorted Array through Instructions

The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.

Hard
1655

Distribute Repeating Integers

Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…

Hard
1659

Maximize Grid Happiness

Maximize Grid Happiness is a dynamic programming problem focusing on state transitions with bitmasking to maximize happi…

Hard
1665

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 …

Hard
1671

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…

Hard
1675

Minimize Deviation in Array

Given a positive integer array, repeatedly double or halve elements to minimize the difference between its largest and s…

Hard
1681

Minimum Incompatibility

Optimize the sum of incompatibilities when distributing an array into subsets with unique elements.

Hard
1687

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…

Hard
1691

Maximum Height by Stacking Cuboids

Maximize the height of stacked cuboids by strategically rotating and stacking them using dynamic programming.

Hard
1697

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…

Hard
1703

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.

Hard
1707

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…

Hard
1713

Minimum Operations to Make a Subsequence

Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…

Hard
1719

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…

Hard
1723

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…

Hard
1728

Cat and Mouse II

Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…

Hard
1735

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…

Hard
1739

Building Boxes

Optimize the number of boxes touching the floor in a cubic room using binary search to minimize floor occupancy.

Hard
1745

Palindrome Partitioning IV

The Palindrome Partitioning IV problem asks you to determine if a string can be split into three palindromic substrings.

Hard
1751

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.

Hard
1755

Closest Subsequence Sum

Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…

Hard
1761

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.

Hard
1766

Tree of Coprimes

Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…

Hard
1770

Maximum Score from Performing Multiplication Operations

Solve the Maximum Score from Performing Multiplication Operations problem using dynamic programming and state transition…

Hard
1771

Maximize Palindrome Length From Subsequences

Maximize Palindrome Length From Subsequences explores dynamic programming to construct the longest palindrome from two s…

Hard
1776

Car Fleet II

Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…

Hard
1782

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.

Hard
1787

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.

Hard
1793

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 …

Hard
1799

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 …

Hard
1803

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 …

Hard
1808

Maximize Number of Nice Divisors

Solve Maximize Number of Nice Divisors by splitting primeFactors into mostly 3s and using fast modular exponentiation.

Hard
1815

Maximum Number of Groups Getting Fresh Donuts

Reorder groups to maximize happy customers by using state transition dynamic programming with bitmasking for optimal bat…

Hard
1819

Number of Different Subsequences GCDs

Given an array of positive integers, find the number of different subsequences' GCDs.

Hard
1825

Finding MK Average

Find the MKAverage of a stream of integers using a queue-driven approach with efficient state management.

Hard
1830

Minimum Number of Operations to Make String Sorted

Calculate the minimum operations to sort a string using combinatorial math and string manipulation techniques efficientl…

Hard
1835

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.

Hard
1840

Maximum Building Height

Find the maximum building height in a city given height restrictions for specific buildings.

Hard
1847

Closest Room

Find the closest hotel room meeting minimum size requirements using binary search over the valid answer space efficientl…

Hard
1851

Minimum Interval to Include Each Query

Find the smallest interval containing each query efficiently using binary search.

Hard
1857

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…

Hard
1862

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…

Hard
1866

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…

Hard
1872

Stone Game VIII

Stone Game VIII requires calculating maximum score difference using state transition dynamic programming on prefix sums …

Hard
1879

Minimum XOR Sum of Two Arrays

Minimize the XOR sum of two integer arrays by rearranging elements using dynamic programming and bit manipulation.

Hard
1883

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…

Hard
1889

Minimum Space Wasted From Packaging

Minimize the wasted space when packaging items into boxes, considering package and box size constraints.

Hard
1896

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…

Hard
1900

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…

Hard
1912

Design Movie Rental System

Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.

Hard
1916

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…

Hard
1923

Longest Common Subpath

The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…

Hard
1928

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.

Hard
1931

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.

Hard
1932

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.

Hard
1938

Maximum Genetic Difference Query

Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.

Hard
1944

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.

Hard
1948

Delete Duplicate Folders in System

Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…

Hard
1955

Count Number of Special Subsequences

Learn to count all valid special subsequences in an array using state transition dynamic programming efficiently and cor…

Hard
1960

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…

Hard
1964

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…

Hard
1970

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.

Hard
1977

Number of Ways to Separate Numbers

Calculate the number of valid non-decreasing integer sequences from a string using state transition dynamic programming …

Hard
1982

Find Array Given Subset Sums

Reconstruct an array from given subset sums using divide and conquer approach and leveraging array properties.

Hard
1987

Number of Unique Good Subsequences

Find the number of unique good subsequences of a binary string using dynamic programming and modular arithmetic.

Hard
1994

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.

Hard
1998

GCD Sort of an Array

The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.

Hard
2003

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…

Hard
2009

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…

Hard
2014

Longest Subsequence Repeated k Times

Find the longest subsequence repeated k times in a string using backtracking search with pruning.

Hard
2019

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…

Hard
2025

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…

Hard
2030

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…

Hard
2035

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…

Hard
2040

Kth Smallest Product of Two Sorted Arrays

Find the kth smallest product from two sorted arrays using binary search across possible product values efficiently.

Hard
2045

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…

Hard
2050

Parallel Courses III

Solve Parallel Courses III by finding the minimum number of months to complete all courses using graph-based topological…

Hard
2056

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…

Hard
2060

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…

Hard
2065

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 …

Hard
2071

Maximum Number of Tasks You Can Assign

Maximize the number of tasks that can be completed by efficiently using workers and magical pills.

Hard
2076

Process Restricted Friend Requests

Determine which friend requests can be accepted without violating direct or indirect restrictions using union-find logic…

Hard
2081

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…

Hard
2088

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.

Hard
2092

Find All People With Secret

Find all people who receive a secret through meetings using graph traversal with depth-first search efficiently and corr…

Hard
2097

Valid Arrangement of Pairs

Given pairs of numbers, find a valid arrangement where each pair follows a specific condition.

Hard
2102

Sequentially Ordinal Rank Tracker

Track rankings of locations with names and scores, adding new locations and retrieving top-ranked ones efficiently.

Hard
2106

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.

Hard
2111

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…

Hard
2117

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…

Hard
2122

Recover the Original Array

Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…

Hard
2127

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…

Hard
2132

Stamping the Grid

Determine if a binary grid can be fully covered using fixed-size stamps by applying a greedy placement and validation st…

Hard
2136

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…

Hard
2141

Maximum Running Time of N Computers

Solve the problem of determining the maximum running time of n computers using a set of batteries.

Hard
2147

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…

Hard
2151

Maximum Good People Based on Statements

Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.

Hard
2156

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.

Hard
2157

Groups of Strings

Group words into connected sets using operations on characters with string and bit manipulation techniques.

Hard
2163

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…

Hard
2167

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.

Hard
2172

Maximum AND Sum of Array

Find the maximum AND sum by placing integers into limited slots using state transition dynamic programming efficiently.

Hard
2179

Count Good Triplets in an Array

Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.

Hard
2183

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.

Hard
2188

Minimum Time to Finish the Race

Minimize the time to complete a race with tire swaps using dynamic programming and state transitions.

Hard
2193

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.

Hard
2197

Replace Non-Coprime Numbers in Array

Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…

Hard
2203

Minimum Weighted Subgraph With the Required Paths

Find the minimum weighted subgraph that connects three specified nodes in a directed graph with constraints.

Hard
2209

Minimum White Tiles After Covering With Carpets

Find the minimum number of white tiles visible after optimally placing carpets using state transition dynamic programmin…

Hard
2213

Longest Substring of One Repeating Character

Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…

Hard
2218

Maximum Value of K Coins From Piles

Optimize coin selection across multiple piles using state transition dynamic programming to achieve the maximum wallet v…

Hard
2223

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…

Hard
2227

Encrypt and Decrypt Strings

The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …

Hard
2234

Maximum Total Beauty of the Gardens

Determine the maximum total beauty of gardens by strategically planting flowers using binary search over achievable flow…

Hard
2242

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.

Hard
2246

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…

Hard
2251

Number of Flowers in Full Bloom

Find the number of flowers in full bloom at the given times for a list of people.

Hard
2258

Escape the Spreading Fire

Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…

Hard
2262

Total Appeal of A String

Calculate the total appeal of all substrings by counting distinct characters efficiently using state transition DP and h…

Hard
2267

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.

Hard
2272

Substring With Largest Variance

Find the largest variance possible in any substring of a given string using dynamic programming.

Hard
2276

Count Integers in Intervals

Design and implement a data structure to efficiently add intervals and count the total number of integers covered by the…

Hard
2281

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…

Hard
2286

Booking Concert Tickets in Groups

Design a ticketing system to allocate concert seats in specific groupings while efficiently handling seat reservations.

Hard
2290

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.

Hard
2296

Design a Text Editor

Design a text editor that supports text manipulation and cursor navigation operations efficiently with linked-list-based…

Hard
2301

Match Substring After Replacement

Determine if a target substring can appear in a string after optional character replacements using given mappings effici…

Hard
2302

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…

Hard
2306

Naming a Company

The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…

Hard
2312

Selling Pieces of Wood

Maximize your profit by cutting a wooden piece into smaller parts based on given prices and dimensions.

Hard
2318

Number of Distinct Roll Sequences

Calculate the number of distinct sequences of dice rolls based on specific conditions using dynamic programming.

Hard
2321

Maximum Score Of Spliced Array

Maximize the score of two arrays by splicing and swapping a subarray using dynamic programming.

Hard
2322

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.

Hard
2328

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…

Hard
2334

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…

Hard
2338

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…

Hard
2344

Minimum Deletions to Make Array Divisible

Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.

Hard
2350

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…

Hard
2354

Number of Excellent Pairs

Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…

Hard
2360

Longest Cycle in a Graph

The problem asks to find the longest cycle in a directed graph with specific edge constraints.

Hard
2366

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…

Hard
2376

Count Special Integers

Count the number of special integers in the interval [1, n] where digits of each integer are distinct.

Hard
2382

Maximum Segment Sum After Removals

Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…

Hard
2386

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…

Hard
2392

Build a Matrix With Conditions

Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…

Hard
2398

Maximum Number of Robots Within Budget

Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…

Hard
2402

Meeting Rooms III

Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.

Hard
2407

Longest Increasing Subsequence II

Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…

Hard
2412

Minimum Money Required Before Transactions

Find the minimum money required to complete all transactions in any order while considering cost and cashback.

Hard
2416

Sum of Prefix Scores of Strings

The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …

Hard
2421

Number of Good Paths

Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.

Hard
2426

Number of Pairs Satisfying Inequality

Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.

Hard
2430

Maximum Deletions on a String

Find the maximum number of deletions on a string using state transition dynamic programming and rolling hash techniques …

Hard
2435

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…

Hard
2440

Create Components With Same Value

Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.

Hard
2444

Count Subarrays With Fixed Bounds

Count all subarrays where the minimum and maximum match given bounds using efficient sliding window tracking techniques.

Hard
2448

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.

Hard
2449

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 …

Hard
2454

Next Greater Element IV

Find the second greater integer for each element in an array using binary search and monotonic stack techniques.

Hard
2458

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…

Hard
2463

Minimum Total Distance Traveled

Optimize the total distance traveled by robots to factories using dynamic programming, sorting, and state transitions.

Hard
2468

Split Message Based on Limit

Split Message Based on Limit requires dividing a string into parts with length constraints using a calculated suffix pat…

Hard
2472

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…

Hard
2478

Number of Beautiful Partitions

The problem involves finding the number of beautiful partitions in a string with dynamic programming and state transitio…

Hard
2484

Count Palindromic Subsequences

Count the number of palindromic subsequences of length 5 in a given string of digits.

Hard
2488

Count Subarrays With Median K

Count the number of subarrays in a given array with median equal to a specified value k.

Hard
2493

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…

Hard
2499

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.

Hard
2503

Maximum Number of Points From Grid Queries

Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.

Hard
2508

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.

Hard
2509

Cycle Length Queries in a Tree

Solve the problem of determining cycle lengths in a binary tree with added edges through queries.

Hard
2514

Count Anagrams

Learn to count distinct anagrams for a multi-word string using hash tables, math, and combinatorics efficiently.

Hard
2518

Number of Great Partitions

Calculate the number of great partitions of an array using state transition dynamic programming with careful sum constra…

Hard
2528

Maximize the Minimum Powered City

Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…

Hard
2532

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…

Hard
2538

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…

Hard
2543

Check if Point Is Reachable

Determine if a target point is reachable from (1,1) using math-based moves following number theory rules efficiently.

Hard
2547

Minimum Cost to Split an Array

Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…

Hard
2551

Put Marbles in Bags

The "Put Marbles in Bags" problem challenges you to distribute marbles into bags for maximum score difference using gree…

Hard
2552

Count Increasing Quadruplets

Given a permutation of numbers, count the number of increasing quadruplets using dynamic programming.

Hard
2561

Rearranging Fruits

Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…

Hard
2565

Subsequence With the Minimum Score

Find the minimum score of a string by removing characters from t while maintaining subsequence validity with s.

Hard
2569

Handling Sum Queries After Update

Solve the Handling Sum Queries After Update problem using arrays and segment trees with lazy propagation for efficiency.

Hard
2573

Find the String with LCP

Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.

Hard
2577

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…

Hard
2581

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.

Hard
2584

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…

Hard
2585

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.

Hard
2589

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…

Hard
2603

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…

Hard
2608

Shortest Cycle in a Graph

Find the shortest cycle in a bi-directional graph using BFS for optimal traversal.

Hard
2612

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…

Hard
2617

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…

Hard
2630

Memoize II

Implementing a memoized function ensures that identical inputs avoid redundant calls, boosting efficiency and performanc…

Hard
2642

Design Graph With Shortest Path Calculator

Implement a dynamic weighted directed graph with efficient shortest path queries and edge additions in real time.

Hard
2646

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…

Hard
2650

Design Cancellable Function

Master designing cancellable functions with generators, handling promise flow, cancellation, and error propagation effec…

Hard
2659

Make Array Empty

Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.

Hard
2663

Lexicographically Smallest Beautiful String

Find the lexicographically smallest beautiful string larger than the given string using greedy choice and invariant vali…

Hard
2681

Power of Heroes

Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…

Hard
2699

Modify Graph Edge Weights

Modify Graph Edge Weights is a graph problem where you adjust edge weights to match a target shortest path distance.

Hard
2709

Greatest Common Divisor Traversal

Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.

Hard
2713

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…

Hard
2719

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…

Hard
2732

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…

Hard
2736

Maximum Sum Queries

Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…

Hard
2742

Painting the Walls

Compute the minimum cost to paint all walls using a paid and free painter with state transition dynamic programming.

Hard
2751

Robot Collisions

Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.

Hard
2763

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.

Hard
2781

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.

Hard
2790

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…

Hard
2791

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 …

Hard
2801

Count Stepping Numbers in Range

Count the stepping numbers in a range using dynamic programming with state transitions between digits.

Hard
2809

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…

Hard
2813

Maximum Elegance of a K-Length Subsequence

Maximize elegance of a k-length subsequence from a list of items with profits and categories.

Hard
2818

Apply Operations to Maximize Score

Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.

Hard
2827

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.

Hard
2835

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 …

Hard
2836

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…

Hard
2842

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…

Hard
2846

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.

Hard
2851

String Transformation

Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.

Hard
2858

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…

Hard
2862

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.

Hard
2867

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.

Hard
2872

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.

Hard
2876

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…

Hard
2897

Apply Operations on Array to Maximize Sum of Squares

Maximizing the sum of squares in an array through bitwise operations on selected elements.

Hard
2902

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.

Hard
2911

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…

Hard
2916

Subarrays Distinct Element Sum of Squares II

Compute the sum of squares of distinct elements in all subarrays using state transition dynamic programming efficiently.

Hard
2920

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.

Hard
2926

Maximum Balanced Subsequence Sum

Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…

Hard
2931

Maximum Spending After Buying Items

Maximize spending by carefully choosing the right items across multiple shops over m * n days.

Hard
2935

Maximum Strong Pair XOR II

Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.

Hard
2940

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.

Hard
2945

Find Maximum Non-decreasing Array Length

Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…

Hard
2949

Count Beautiful Substrings II

Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.

Hard
2953

Count Complete Substrings

Count Complete Substrings involves finding substrings where each character appears exactly k times with constraints on a…

Hard
2954

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…

Hard
2959

Number of Possible Sets of Closing Branches

Calculate all valid sets of branch closures while keeping remaining branches within maxDistance using bitmask and graph …

Hard
2963

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…

Hard
2968

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…

Hard
2972

Count the Number of Incremovable Subarrays II

Count the number of incremovable subarrays where removal of the subarray results in a strictly increasing array.

Hard
2973

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.

Hard
2977

Minimum Cost to Convert String II

Compute the minimum cost to transform source into target using substring replacements with given costs efficiently using…

Hard
2983

Palindrome Rearrangement Queries

Given a string and queries, check if rearranging specified substrings can make the string a palindrome.

Hard
2999

Count the Number of Powerful Integers

Count the number of powerful integers in a given range by applying state transition dynamic programming with constraints…

Hard
3003

Maximize the Number of Partitions After Operations

Maximizing the number of partitions in a string after changing one character and applying partitioning operations using …

Hard
3008

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.

Hard
3013

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.

Hard
3017

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…

Hard
3022

Minimize OR of Remaining Elements Using Operations

Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.

Hard
3027

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…

Hard
3031

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…

Hard
3036

Number of Subarrays That Match a Pattern II

Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.

Hard
3041

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…

Hard
3045

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 …

Hard
3049

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…

Hard
3068

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…

Hard
3072

Distribute Elements Into Two Arrays II

Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…

Hard
3077

Maximum Strength of K Disjoint Subarrays

Solve Maximum Strength of K Disjoint Subarrays with dynamic programming that tracks segment state, sign changes, and wei…

Hard
3082

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.

Hard
3086

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.

Hard
3093

Longest Common Suffix Queries

Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…

Hard
3098

Find the Sum of Subsequence Powers

Compute the sum of powers for all subsequences of length k using state transition dynamic programming efficiently.

Hard
3102

Minimize Manhattan Distances

Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.

Hard
3108

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…

Hard
3113

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…

Hard
3116

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…

Hard
3117

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.

Hard
3123

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.

Hard
3130

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…

Hard
3134

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…

Hard
3139

Minimum Cost to Equalize Array

Compute the minimum cost to make all elements equal using selective operations guided by greedy choices and invariant ch…

Hard
3145

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…

Hard
3149

Find the Minimum Cost Array Permutation

Determine the lexicographically smallest permutation of nums that minimizes a cyclic score using state transition DP tec…

Hard
3154

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…

Hard
3161

Block Placement Queries

Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…

Hard
3165

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…

Hard
3171

Find Subarray With Bitwise OR Closest to K

Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.

Hard
3177

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.

Hard
3181

Maximum Total Reward Using Operations II

Maximize your total reward using dynamic programming with state transitions in this challenging problem involving array …

Hard
3187

Peaks in Array

Determine peaks in a dynamic integer array using efficient Binary Indexed Tree updates and range queries for fast result…

Hard
3193

Count the Number of Inversions

Count the number of valid permutations satisfying inversion constraints using state transition dynamic programming.

Hard
3197

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.

Hard
3203

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…

Hard
3209

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…

Hard
3213

Construct String with Minimum Cost

This problem asks you to construct a target string using given words at minimal cost using dynamic programming technique…

Hard
3219

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…

Hard
3225

Maximum Score From Grid Operations

Maximize your score by choosing the optimal sequence of column operations on a grid using dynamic programming transition…

Hard
3229

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…

Hard
3235

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.

Hard
3241

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.

Hard
3244

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…

Hard
3245

Alternating Groups III

Solve Alternating Groups III using array manipulation and a binary indexed tree to track maximal alternating sequences e…

Hard
3250

Find the Count of Monotonic Pairs I

Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.

Hard
3251

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…

Hard
3256

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.

Hard
3257

Maximum Value Sum by Placing Three Rooks II

Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.

Hard
3260

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…

Hard
3261

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…

Hard
3266

Final Array State After K Multiplication Operations II

Optimize the final state of an array after performing k multiplication operations with priority queues.

Hard
3267

Count Almost Equal Pairs II

Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.

Hard
3272

Find the Count of Good Integers

Count good integers by rearranging digits to form k-palindromic numbers, leveraging hash tables and math techniques.

Hard
3273

Minimum Amount of Damage Dealt to Bob

Minimize the total damage dealt to Bob using power to eliminate enemies efficiently with greedy approach.

Hard
3276

Select Cells in Grid With Maximum Score

Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.

Hard
3277

Maximum XOR Score Subarray Queries

Solve the Maximum XOR Score Subarray Queries problem using state transition dynamic programming for optimal subarray com…

Hard
3283

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…

Hard
3287

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…

Hard
3288

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…

Hard
3292

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…

Hard
3298

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…

Hard
3303

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.

Hard
3307

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…

Hard
3311

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.

Hard
3312

Sorted GCD Pair Queries

Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…

Hard
3317

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.

Hard
3320

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…

Hard
3321

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.

Hard
3327

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…

Hard
3333

Find the Original Typed String II

Calculate how many potential original strings Alice might have intended to type, considering her clumsy typing behavior.

Hard
3336

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…

Hard
3337

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…

Hard
3343

Count Number of Balanced Permutations

Determine how many distinct permutations of a digit string are balanced using state transition dynamic programming effic…

Hard
3347

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…

Hard
3348

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…

Hard
3351

Sum of Good Subsequences

Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.

Hard
3352

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.

Hard
3357

Minimize the Maximum Adjacent Element Difference

Minimize the maximum adjacent element difference by filling missing values with two chosen numbers.

Hard
3363

Find the Maximum Number of Fruits Collected

Maximize the number of fruits collected by three children navigating a grid dungeon with dynamic programming.

Hard
3367

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.

Hard
3373

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.

Hard
3378

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…

Hard
3382

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…

Hard
3389

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…

Hard
3395

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.

Hard
3398

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.

Hard
3399

Smallest Substring With Identical Characters II

Find the minimal length of a substring with identical characters using binary search and controlled character flips effi…

Hard
3405

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…

Hard
3410

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…

Hard
3414

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…

Hard
3420

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.

Hard
3425

Longest Special Path

Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.

Hard
3426

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.

Hard
3430

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…

Hard
3435

Frequencies of Shortest Supersequences

Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …

Hard
3441

Minimum Cost Good Caption

Solve Minimum Cost Good Caption with dynamic programming that builds minimum edit cost while enforcing character runs of…

Hard
3444

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…

Hard
3445

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…

Hard
3448

Count Substrings Divisible By Last Digit

Count the number of substrings in a string divisible by their last non-zero digit using dynamic programming.

Hard
3449

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…

Hard
3454

Separate Squares II

Separate Squares II requires finding the minimum y-coordinate such that squares' areas are split evenly above and below …

Hard
3455

Shortest Matching Substring

Find the shortest substring in a string that matches a pattern with exactly two wildcards efficiently using binary searc…

Hard
3459

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…

Hard
3463

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…

Hard
3464

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…

Hard
3470

Permutations IV

Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…

Hard
3474

Lexicographically Smallest Generated String

Generate the lexicographically smallest string by merging str1 and str2 using a greedy approach with invariant checks.

Hard
3480

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…

Hard
3485

Longest Common Prefix of K Strings After Removal

Find the longest common prefix length of k strings after removing an element in the array.

Hard
3486

Longest Special Path II

Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…

Hard
3490

Count Beautiful Numbers

Count Beautiful Numbers using state transition dynamic programming to efficiently calculate valid numbers in a given ran…

Hard
3495

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…

Hard
3500

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…

Hard
3501

Maximize Active Section with Trade II

Maximize the number of active sections in a binary string with at most one trade.

Hard
3504

Longest Palindrome After Substring Concatenation II

Compute the longest palindrome by concatenating substrings from two strings using state transition dynamic programming e…

Hard
3505

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…

Hard
3509

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.

Hard
3510

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.

Hard
3515

Shortest Path in a Weighted Tree

Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.

Hard
3518

Smallest Palindromic Rearrangement II

Find the k-th lexicographically smallest palindromic rearrangement of a given palindromic string s.

Hard
3519

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…

Hard
3525

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…

Hard
3530

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…

Hard
3533

Concatenated Divisibility

Find the lexicographically smallest permutation of numbers whose concatenation is divisible by k using state transition …

Hard
3534

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…

Hard
3538

Merge Operations for Minimum Travel Time

Minimize the total travel time by merging road signs, using dynamic programming to manage state transitions efficiently.

Hard
3539

Find Sum of Array Product of Magical Sequences

Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…

Hard
3544

Subtree Inversion Sum

This problem involves calculating the maximum possible subtree inversion sum with dynamic programming and binary-tree tr…

Hard
3547

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.

Hard
3548

Equal Sum Grid Partition II

Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.

Hard
3553

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…

Hard
3559

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.

Hard
3562

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…

Hard
3563

Lexicographically Smallest String After Adjacent Removals

Find the lexicographically smallest string by repeatedly removing adjacent characters optimally using dynamic programmin…

Hard
3569

Maximize Count of Distinct Primes After Split

Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…

Hard
3574

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 …

Hard
3575

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…

Hard
3579

Minimum Steps to Convert String with Operations

Transform word1 into word2 using minimal operations on substrings with a dynamic programming state transition approach.

Hard
3585

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…

Hard
3590

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-…

Hard
3594

Minimum Time to Transport All Individuals

Find the minimum time to transport individuals across a river with dynamic environmental conditions and boat capacity.

Hard
3600

Maximize Spanning Tree Stability with Upgrades

Maximizing the stability of a spanning tree with upgrades requires careful optimization of edge strengths using binary s…

Hard
3605

Minimum Stability Factor of Array

The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…

Hard
3609

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.

Hard
3614

Process String with Special Operations II

Solve the problem of processing strings with special operations like '*' and '#' by simulating the rules left-to-right.

Hard
3615

Longest Palindromic Path in Graph

Find the longest path in a graph that forms a palindrome using state transition dynamic programming and bitmask techniqu…

Hard
3617

Find Students with Study Spiral Pattern

Solve Find Students with Study Spiral Pattern by validating each student's ordered subject cycle, consistency, and repea…

Hard
3620

Network Recovery Pathways

Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.

Hard
3621

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…

Hard
3624

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…

Hard
3625

Count Number of Trapezoids II

Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…

Hard
3630

Partition Array for Maximum XOR and AND

Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.

Hard
3636

Threshold Majority Queries

Find the majority element in subarrays that appear at least a threshold number of times, or -1 if none exists.

Hard
3640

Trionic Array II

Trionic Array II is a challenging problem involving the sum of contiguous subarrays with special index constraints.

Hard

Top Topics In This Track

route

Guided Practice Path

AI recommends problems by your level and tracks your progress.

Start Guided Patharrow_forward
Hard LeetCode Problems