LeetCode/Medium

Medium Problems

1423 problems

This track helps you build stable solving and explanation quality at this pressure level.

Training Focus

Focus on pattern recognition and trade-off clarity.

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.

2

Add Two Numbers

Add Two Numbers requires careful linked-list pointer manipulation to sum digits while handling carries efficiently in in…

Medium
3

Longest Substring Without Repeating Characters

Find the length of the longest substring without repeating characters using a sliding window and hash map to track state…

Medium
5

Longest Palindromic Substring

Find the longest contiguous palindromic substring in a given string using dynamic programming and two-pointer expansion …

Medium
6

Zigzag Conversion

Convert a string into a zigzag pattern across multiple rows and read it line by line efficiently for string manipulation…

Medium
7

Reverse Integer

Reverse Integer challenges you to invert the digits of a signed 32-bit integer, handling overflow and negative values ca…

Medium
8

String to Integer (atoi)

Convert a string to a 32-bit signed integer by carefully parsing characters, handling signs, and ignoring invalid traili…

Medium
11

Container With Most Water

Find two vertical lines that can form a container with the most water in a given array of heights.

Medium
12

Integer to Roman

Convert a given integer to its Roman numeral representation using hash table mapping and decimal place math operations e…

Medium
15

3Sum

Given an integer array, return all unique triplets where the sum is zero using two-pointer scanning with careful duplica…

Medium
16

3Sum Closest

Find the sum of three integers in an array that is closest to a given target using two-pointer scanning.

Medium
17

Letter Combinations of a Phone Number

Generate all letter combinations a digit string can represent using backtracking with pruning, leveraging hash table map…

Medium
18

4Sum

The 4Sum problem requires finding all unique quadruplets in an array that sum to a specific target value.

Medium
19

Remove Nth Node From End of List

Remove the nth node from the end of a linked list using a two-pointer approach to solve efficiently.

Medium
22

Generate Parentheses

Generate Parentheses requires generating all valid combinations of parentheses with given pairs using backtracking and s…

Medium
24

Swap Nodes in Pairs

Learn how to swap every adjacent linked-list pair by rewiring nodes safely without changing values or breaking the remai…

Medium
29

Divide Two Integers

Solve Divide Two Integers by turning repeated subtraction into bit-shifted chunk subtraction with careful sign and overf…

Medium
31

Next Permutation

Next Permutation is a medium-difficulty problem focusing on generating the next lexicographically greater permutation of…

Medium
33

Search in Rotated Sorted Array

Find the index of a target in a rotated sorted array using a careful binary search that handles pivot shifts.

Medium
34

Find First and Last Position of Element in Sorted Array

Locate the first and last index of a target in a sorted array using binary search for precise O(log n) performance.

Medium
36

Valid Sudoku

Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …

Medium
38

Count and Say

Count and Say requires building the nth sequence term by iteratively applying a run-length encoding on strings of digits…

Medium
39

Combination Sum

Find all unique combinations of numbers from a distinct array that sum to a target using controlled backtracking search.

Medium
40

Combination Sum II

Find all unique combinations of numbers that sum to a target using backtracking with careful pruning to avoid duplicates…

Medium
43

Multiply Strings

Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…

Medium
45

Jump Game II

Jump Game II requires finding the minimum jumps to reach the end of an array using dynamic programming and greedy techni…

Medium
46

Permutations

Generate all possible orderings of a distinct integer array using backtracking search with careful pruning to avoid dupl…

Medium
47

Permutations II

Generate all unique permutations of an array containing duplicates using backtracking and pruning to avoid repeated sequ…

Medium
48

Rotate Image

Rotate an n x n matrix 90 degrees clockwise in-place using array manipulation and mathematical indexing techniques effic…

Medium
49

Group Anagrams

Group the anagrams in a list of strings using efficient hash table-based methods, focusing on array scanning.

Medium
50

Pow(x, n)

Calculate x to the power n efficiently using recursion and exponentiation, handling negative powers and large inputs saf…

Medium
53

Maximum Subarray

Maximum Subarray is a classic state transition dynamic programming problem about deciding whether to extend or restart a…

Medium
54

Spiral Matrix

Given an m x n matrix, return all elements in spiral order starting from the top-left corner.

Medium
55

Jump Game

Solve the Jump Game problem using state transition dynamic programming to determine if you can reach the last index of t…

Medium
56

Merge Intervals

Merge Intervals requires sorting an array of interval pairs and combining overlaps efficiently using sequential comparis…

Medium
57

Insert Interval

Given a sorted array of non-overlapping intervals, insert a new interval and merge any overlapping intervals.

Medium
59

Spiral Matrix II

Generate a spiral matrix of size n x n, filled with elements from 1 to n² in spiral order, for interview-focused solving…

Medium
61

Rotate List

Rotate a singly linked list to the right by k positions using careful pointer manipulation and two-pointer traversal tec…

Medium
62

Unique Paths

Calculate the number of unique paths for a robot to move on an m x n grid with only right and down movements.

Medium
63

Unique Paths II

Calculate the number of unique paths from top-left to bottom-right in a grid with obstacles using dynamic programming st…

Medium
64

Minimum Path Sum

Compute the minimum sum from top-left to bottom-right in a grid using state transition dynamic programming efficiently.

Medium
71

Simplify Path

Simplify a Unix-style path by transforming it into its canonical form using stack-based state management.

Medium
72

Edit Distance

Determine the minimum number of insertions, deletions, or replacements to transform one string into another using dynami…

Medium
73

Set Matrix Zeroes

Modify the matrix in place by setting rows and columns to zero when an element is zero.

Medium
74

Search a 2D Matrix

Search a 2D matrix efficiently using binary search over its linearized index, ensuring correctness in row-major sorted a…

Medium
75

Sort Colors

Sort Colors requires in-place reordering of an array using a two-pointer scanning strategy to group 0s, 1s, and 2s effic…

Medium
77

Combinations

Generate all combinations of k numbers from the range [1, n] using backtracking and pruning.

Medium
78

Subsets

Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.

Medium
79

Word Search

Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.

Medium
80

Remove Duplicates from Sorted Array II

Solve the problem of removing duplicates from a sorted array in-place, ensuring each element appears at most twice, usin…

Medium
81

Search in Rotated Sorted Array II

Determine if a target exists in a rotated sorted array that may contain duplicates using a binary search variation effic…

Medium
82

Remove Duplicates from Sorted List II

Remove duplicates from a sorted linked list, leaving only distinct values, and return the modified list in sorted order.

Medium
86

Partition List

Partition a linked list such that all nodes less than x come before nodes greater than or equal to x while preserving re…

Medium
89

Gray Code

Generate an n-bit Gray Code sequence using backtracking with pruning and bit manipulation techniques.

Medium
90

Subsets II

Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…

Medium
91

Decode Ways

Decode Ways is a dynamic programming problem focused on decoding a numeric string to letters using specific mappings.

Medium
92

Reverse Linked List II

Reverse a segment of a singly linked list from position left to right using precise pointer manipulation techniques.

Medium
93

Restore IP Addresses

Restore all valid IP addresses from a string using backtracking with pruning, avoiding invalid segments or leading zeros…

Medium
95

Unique Binary Search Trees II

Generate all structurally unique BSTs with values 1 to n using backtracking and recursive tree construction techniques.

Medium
96

Unique Binary Search Trees

Given n nodes, calculate the number of unique binary search trees (BSTs) that can be formed with values from 1 to n.

Medium
97

Interleaving String

The Interleaving String problem requires determining if a string can be formed by interleaving two others, utilizing dyn…

Medium
98

Validate Binary Search Tree

Validate Binary Search Tree problem checks if a binary tree satisfies BST properties using tree traversal and state trac…

Medium
99

Recover Binary Search Tree

Recover a BST where two nodes are swapped by mistake using in-order traversal and careful state tracking to restore corr…

Medium
102

Binary Tree Level Order Traversal

Perform a level order traversal on a binary tree using BFS to return node values level by level.

Medium
103

Binary Tree Zigzag Level Order Traversal

Traverse a binary tree in zigzag level order, alternating directions at each depth using BFS and state tracking techniqu…

Medium
105

Construct Binary Tree from Preorder and Inorder Traversal

Construct a binary tree using preorder and inorder traversal arrays, leveraging array scanning and hash table lookups.

Medium
106

Construct Binary Tree from Inorder and Postorder Traversal

Reconstruct a binary tree from given inorder and postorder arrays using array scanning and hash lookup to optimize recur…

Medium
107

Binary Tree Level Order Traversal II

Return a bottom-up level order traversal of a binary tree, processing nodes left to right while tracking each level accu…

Medium
109

Convert Sorted List to Binary Search Tree

Convert a sorted singly linked list into a height-balanced BST using pointer manipulation and divide-and-conquer recursi…

Medium
113

Path Sum II

Find all root-to-leaf paths in a binary tree where the sum of node values equals a given target using DFS backtracking.

Medium
114

Flatten Binary Tree to Linked List

Flatten a binary tree into a right-skewed linked list by manipulating pointers following a pre-order traversal, handling…

Medium
116

Populating Next Right Pointers in Each Node

Connect each node across every level by reusing established next links to traverse a perfect binary tree without extra q…

Medium
117

Populating Next Right Pointers in Each Node II

Populate each next pointer in a binary tree to its immediate right node, handling nulls and uneven levels efficiently us…

Medium
120

Triangle

Given a triangle, return the minimum path sum from top to bottom, moving to adjacent numbers in the row below.

Medium
122

Best Time to Buy and Sell Stock II

Maximize stock profit by using a greedy approach to buy and sell multiple times, with state transition dynamic programmi…

Medium
128

Longest Consecutive Sequence

Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.

Medium
129

Sum Root to Leaf Numbers

Calculate the sum of all root-to-leaf numbers in a binary tree where each path represents a number.

Medium
130

Surrounded Regions

Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.

Medium
131

Palindrome Partitioning

Find all possible palindrome partitioning of a string using backtracking and dynamic programming.

Medium
133

Clone Graph

Clone Graph involves cloning a graph using DFS, focusing on graph traversal and neighbor management using hash tables.

Medium
134

Gas Station

The Gas Station problem requires finding the starting station index for a full circular trip with gas stations and costs…

Medium
137

Single Number II

Find the single element in an array where every other element appears three times, using bit manipulation and constant s…

Medium
138

Copy List with Random Pointer

This problem requires copying a linked list where each node has a random pointer in addition to the next pointer.

Medium
139

Word Break

Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…

Medium
142

Linked List Cycle II

Identify the start of a cycle in a linked list using pointer manipulation, efficiently handling edge cases without modif…

Medium
143

Reorder List

Reorder List requires careful pointer manipulation in a singly linked list to interleave nodes from the ends without alt…

Medium
146

LRU Cache

Implement an efficient LRU Cache using hash table and doubly-linked list to achieve O(1) operations for get and put.

Medium
147

Insertion Sort List

Sort a singly linked list using insertion sort by carefully manipulating pointers to maintain a sorted order efficiently…

Medium
148

Sort List

Sort List requires sorting a singly linked list efficiently using pointer manipulation and merge sort for optimal perfor…

Medium
150

Evaluate Reverse Polish Notation

Compute the result of an arithmetic expression in Reverse Polish Notation using a stack to manage operands efficiently.

Medium
151

Reverse Words in a String

Reverse Words in a String requires reordering words using precise two-pointer scanning with careful space handling for e…

Medium
152

Maximum Product Subarray

Find the subarray with the largest product in an integer array using dynamic programming techniques.

Medium
153

Find Minimum in Rotated Sorted Array

Find the minimum element in a rotated sorted array using binary search to efficiently identify the point of rotation.

Medium
155

Min Stack

Design a stack with O(1) operations to push, pop, retrieve the top element, and get the minimum element in constant time…

Medium
162

Find Peak Element

Find Peak Element leverages binary search for efficiently locating a peak in an array, a problem commonly asked in techn…

Medium
164

Maximum Gap

Find the largest difference between successive elements in a sorted array efficiently using linear time techniques and b…

Medium
165

Compare Version Numbers

Compare two version numbers by checking their individual revisions, considering missing revisions as zero, using a two-p…

Medium
166

Fraction to Recurring Decimal

Convert a fraction into a decimal, handling repeating decimals with parentheses around the repeating part.

Medium
167

Two Sum II - Input Array Is Sorted

Solve the Two Sum II problem efficiently using binary search over a valid answer space in a sorted array.

Medium
172

Factorial Trailing Zeroes

Given a number n, find how many trailing zeroes are in n! using a math-driven approach.

Medium
173

Binary Search Tree Iterator

Implement an iterator for in-order traversal of a binary search tree (BST), maintaining traversal state with stack-based…

Medium
179

Largest Number

The problem asks to arrange integers to form the largest possible number, focusing on greedy algorithms and string handl…

Medium
187

Repeated DNA Sequences

Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.

Medium
189

Rotate Array

Rotate Array challenges you to shift elements right by k steps using precise two-pointer scanning and invariant tracking…

Medium
198

House Robber

Maximize the amount of money you can rob tonight without alerting the police by applying dynamic programming with state …

Medium
199

Binary Tree Right Side View

The Binary Tree Right Side View problem asks you to return the visible nodes from the right side of a binary tree, trave…

Medium
200

Number of Islands

Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…

Medium
201

Bitwise AND of Numbers Range

Use shared high bits and bit clearing to solve Bitwise AND of Numbers Range without scanning every value.

Medium
204

Count Primes

Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.

Medium
207

Course Schedule

Determine if all courses can be completed by analyzing prerequisite dependencies using indegree tracking and topological…

Medium
208

Implement Trie (Prefix Tree)

This problem requires designing a Trie (Prefix Tree) to efficiently store and query strings using hash table concepts fo…

Medium
209

Minimum Size Subarray Sum

Find the minimal length of a subarray whose sum is greater than or equal to the target using efficient algorithms.

Medium
210

Course Schedule II

Solve the 'Course Schedule II' problem using graph indegree and topological ordering, utilizing DFS or BFS to find the c…

Medium
211

Design Add and Search Words Data Structure

Build a WordDictionary supporting dynamic word addition and search with wildcard matching efficiently using Trie and DFS…

Medium
213

House Robber II

Maximize your loot by robbing houses arranged in a circle without alerting the police using dynamic programming.

Medium
215

Kth Largest Element in an Array

Find the kth largest element in an unsorted array using optimal approaches like Quickselect or heaps.

Medium
216

Combination Sum III

Find all unique combinations of k numbers adding to n using efficient backtracking with pruning in arrays.

Medium
221

Maximal Square

Maximal Square is a matrix-based dynamic programming problem that focuses on finding the largest square filled with 1's.

Medium
223

Rectangle Area

Calculate the total area covered by two rectangles using geometry, handling overlaps and avoiding double counting effici…

Medium
227

Basic Calculator II

Basic Calculator II evaluates a mathematical expression with operators and integers, handling basic arithmetic with prec…

Medium
229

Majority Element II

Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…

Medium
230

Kth Smallest Element in a BST

Find the kth smallest element in a BST by leveraging in-order traversal to efficiently track node order and count.

Medium
235

Lowest Common Ancestor of a Binary Search Tree

Find the lowest common ancestor (LCA) of two nodes in a binary search tree, using binary-tree traversal and state tracki…

Medium
236

Lowest Common Ancestor of a Binary Tree

Identify the lowest common ancestor of two nodes in a binary tree using traversal and state tracking techniques efficien…

Medium
237

Delete Node in a Linked List

Delete Node in a Linked List focuses on pointer manipulation to delete a node in a singly linked list without access to …

Medium
238

Product of Array Except Self

Solve the 'Product of Array Except Self' problem by calculating the product of all elements except self for each index e…

Medium
240

Search a 2D Matrix II

Efficiently search for a target in a 2D matrix using binary search and matrix properties.

Medium
241

Different Ways to Add Parentheses

Solve Different Ways to Add Parentheses by splitting on each operator and memoizing every subexpression result list.

Medium
260

Single Number III

Find the two unique numbers in an array where all other numbers appear exactly twice using bit manipulation efficiently.

Medium
264

Ugly Number II

Find the nth ugly number, where ugly numbers have prime factors limited to 2, 3, and 5.

Medium
274

H-Index

Determine a researcher's h-index by analyzing citations using array sorting and counting techniques efficiently and accu…

Medium
275

H-Index II

Compute a researcher's H-Index from a sorted citation array using binary search over the valid answer space efficiently.

Medium
279

Perfect Squares

Perfect Squares asks for the least number of perfect squares summing to a given integer n using dynamic programming or B…

Medium
284

Peeking Iterator

Design an iterator with peek functionality, adding to the standard next and hasNext operations for efficient element acc…

Medium
287

Find the Duplicate Number

The problem involves finding the duplicate number in an array of integers, using a binary search approach over the valid…

Medium
289

Game of Life

Solve the Game of Life by updating each cell based on its eight neighbors using Array and Matrix simulation patterns eff…

Medium
299

Bulls and Cows

Solve the Bulls and Cows problem using hash tables and string manipulation to track exact and misplaced digits.

Medium
300

Longest Increasing Subsequence

Solve the Longest Increasing Subsequence problem using dynamic programming and binary search to efficiently find the sub…

Medium
304

Range Sum Query 2D - Immutable

Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.

Medium
306

Additive Number

Additive Number is solved by trying the first two splits, then pruning aggressively while verifying each required sum in…

Medium
307

Range Sum Query - Mutable

Implement a mutable range sum query using efficient design patterns to handle multiple updates and range sum queries.

Medium
309

Best Time to Buy and Sell Stock with Cooldown

Maximize stock profit with cooldown restrictions using state transition dynamic programming to track buy, sell, and cool…

Medium
310

Minimum Height Trees

Identify all roots of a tree that produce minimum height using graph indegree analysis and topological trimming.

Medium
313

Super Ugly Number

Compute the nth super ugly number efficiently using dynamic programming with state transitions based on the given prime …

Medium
316

Remove Duplicate Letters

Remove duplicate letters from a string to produce the lexicographically smallest result using stack-based state manageme…

Medium
318

Maximum Product of Word Lengths

The problem requires finding the maximum product of lengths of two words from an array, where the words don't share comm…

Medium
319

Bulb Switcher

Bulb Switcher challenges you to find how many bulbs remain on after n toggling rounds using a math-based insight.

Medium
322

Coin Change

Find the minimum number of coins needed to reach a target amount using dynamic programming state transitions efficiently…

Medium
324

Wiggle Sort II

Rearrange an array in a way that every odd-indexed element is greater than its adjacent even-indexed elements.

Medium
328

Odd Even Linked List

Reorder a singly linked list by grouping odd-indexed nodes first, followed by even-indexed nodes while preserving relati…

Medium
331

Verify Preorder Serialization of a Binary Tree

Determine if a given string correctly represents a binary tree preorder traversal using state tracking and slot counting…

Medium
334

Increasing Triplet Subsequence

Identify if an array contains a strictly increasing triplet by maintaining a running minimal and middle value efficientl…

Medium
337

House Robber III

Maximize the loot by robbing non-adjacent houses in a binary tree structure using dynamic programming and DFS.

Medium
341

Flatten Nested List Iterator

Implement an iterator to flatten a nested list of integers, accounting for potential nesting levels.

Medium
343

Integer Break

Break an integer into the sum of positive integers to maximize the product using dynamic programming.

Medium
347

Top K Frequent Elements

Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.

Medium
355

Design Twitter

Design Twitter requires implementing post, follow, unfollow, and news feed retrieval using linked-list pointer manipulat…

Medium
357

Count Numbers with Unique Digits

The problem asks to count numbers with unique digits from 0 to 10^n using dynamic programming, math, and backtracking te…

Medium
365

Water and Jug Problem

Determine if two jugs with given capacities can measure an exact target amount using math and DFS strategies efficiently…

Medium
368

Largest Divisible Subset

Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…

Medium
371

Sum of Two Integers

Solve the Sum of Two Integers problem using bit manipulation and math to avoid using the operators + and -.

Medium
372

Super Pow

Compute large exponentiations efficiently using modular arithmetic and divide-and-conquer techniques for this Super Pow …

Medium
373

Find K Pairs with Smallest Sums

Find K Pairs with Smallest Sums combines arrays and heap usage to select the smallest sum pairs efficiently.

Medium
375

Guess Number Higher or Lower II

Minimize the maximum cost of guessing a number in a dynamic guessing game using optimal strategies.

Medium
376

Wiggle Subsequence

Find the longest wiggle subsequence in an integer array using state transition dynamic programming with greedy optimizat…

Medium
377

Combination Sum IV

Combination Sum IV asks to find the number of combinations that sum to a given target using elements from an array.

Medium
378

Kth Smallest Element in a Sorted Matrix

Find the kth smallest element in a sorted n x n matrix using efficient binary search or heap strategies for optimized me…

Medium
380

Insert Delete GetRandom O(1)

Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.

Medium
382

Linked List Random Node

Select a random node from a singly linked list ensuring uniform probability using efficient pointer techniques and reser…

Medium
384

Shuffle an Array

Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…

Medium
385

Mini Parser

Deserialize a nested list string using stack-based state management, handling integers and nested lists with depth-first…

Medium
386

Lexicographical Numbers

Generate all numbers from 1 to n in lexicographical order using a depth-first search pattern optimized with trie logic f…

Medium
388

Longest Absolute File Path

Find the length of the longest absolute file path in a filesystem string using stack-based depth tracking efficiently.

Medium
390

Elimination Game

Elimination Game uses a systematic removal of numbers with alternating left-right passes, solvable with math and recursi…

Medium
393

UTF-8 Validation

Determine if an integer array represents valid UTF-8 encoding based on its byte sequences using bit manipulation.

Medium
394

Decode String

Decode a nested encoded string using stack-based state management, handling repeated patterns efficiently with recursion…

Medium
395

Longest Substring with At Least K Repeating Characters

Find the length of the longest substring where every character appears at least k times using sliding window and divide-…

Medium
396

Rotate Function

Maximize the rotation function by rotating the array and calculating the weighted sum for all rotations.

Medium
397

Integer Replacement

Find the minimum number of operations to reduce a number to 1 by applying specific operations, using state transition dy…

Medium
398

Random Pick Index

Random Pick Index involves selecting a random index of a target number in an array with possible duplicates.

Medium
399

Evaluate Division

Compute the results of division queries from given equations using graph traversal and depth-first search efficiently.

Medium
400

Nth Digit

Given n, efficiently find the nth digit in the infinite integer sequence using a binary search over valid positions.

Medium
402

Remove K Digits

Remove K Digits requires selecting which digits to drop using a monotonic stack for the smallest possible integer result…

Medium
406

Queue Reconstruction by Height

Reconstruct a queue based on the given heights and the number of taller people in front, using sorting and binary indexe…

Medium
413

Arithmetic Slices

Count the number of arithmetic subarrays in a given integer array using dynamic programming.

Medium
416

Partition Equal Subset Sum

Determine if an array can be partitioned into two subsets with equal sum using dynamic programming techniques.

Medium
417

Pacific Atlantic Water Flow

Find all cells on an island where water can flow to both the Pacific and Atlantic oceans using DFS or BFS.

Medium
419

Battleships in a Board

Count the number of non-overlapping battleships on a 2D board using array traversal and depth-first search patterns effi…

Medium
421

Maximum XOR of Two Numbers in an Array

Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.

Medium
423

Reconstruct Original Digits from English

This problem asks you to reconstruct digits from an out-of-order English string using hash counting and mathematical ded…

Medium
424

Longest Repeating Character Replacement

Find the length of the longest substring after at most k replacements using a sliding window and character count trackin…

Medium
427

Construct Quad Tree

Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.

Medium
429

N-ary Tree Level Order Traversal

Perform a level order traversal on an n-ary tree, capturing nodes by depth using breadth-first search with careful state…

Medium
430

Flatten a Multilevel Doubly Linked List

Flatten a multilevel doubly linked list by correctly updating next, prev, and child pointers to create a single-level se…

Medium
433

Minimum Genetic Mutation

Determine the minimum number of single-character gene mutations to reach the target gene using BFS and a hash table look…

Medium
435

Non-overlapping Intervals

Determine the minimum number of intervals to remove from a list to ensure no intervals overlap using dynamic programming…

Medium
437

Path Sum III

Path Sum III challenges you to count paths in a binary tree that sum to a given target value with downward traversal.

Medium
438

Find All Anagrams in a String

Find all starting indices of p's anagrams in s using sliding window and hash table approach.

Medium
442

Find All Duplicates in an Array

Find all integers that appear twice in an array with O(n) time and constant space complexity.

Medium
443

String Compression

Compress a character array in-place by converting consecutive repeated characters into counts using two-pointer scanning…

Medium
445

Add Two Numbers II

Add Two Numbers II involves summing two numbers represented as linked lists and returning the result as a new linked lis…

Medium
447

Number of Boomerangs

Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.

Medium
449

Serialize and Deserialize BST

Design an algorithm to serialize and deserialize a binary search tree with efficient traversal and state tracking.

Medium
450

Delete Node in a BST

Delete Node in a BST hinges on removing one target while preserving in-order ordering through carefully chosen subtree r…

Medium
451

Sort Characters By Frequency

Sort Characters By Frequency requires counting characters efficiently and rearranging a string in descending frequency o…

Medium
452

Minimum Number of Arrows to Burst Balloons

Find the minimum number of arrows needed to burst all balloons by considering greedy choice and invariant validation.

Medium
453

Minimum Moves to Equal Array Elements

Compute the fewest steps to make all elements equal by incrementing n-1 array items, applying array and math reasoning.

Medium
454

4Sum II

Count all quadruples from four integer arrays that sum to zero using efficient array scanning and hash table lookups.

Medium
456

132 Pattern

Identify whether a given integer array contains a 132 pattern subsequence using efficient stack and search techniques.

Medium
457

Circular Array Loop

Detect whether a circular array contains a loop of consistent direction using efficient array scanning and hash lookup t…

Medium
462

Minimum Moves to Equal Array Elements II

Find the minimum moves to equalize all array elements using increments or decrements with array and math techniques.

Medium
464

Can I Win

Determine if the first player can guarantee a win in a turn-based number selection game using state transition dynamic p…

Medium
467

Unique Substrings in Wraparound String

Solve the 'Unique Substrings in Wraparound String' problem using dynamic programming with a state transition approach.

Medium
468

Validate IP Address

Determine whether a given string is a valid IPv4 or IPv6 address using a precise string-driven validation strategy.

Medium
470

Implement Rand10() Using Rand7()

Generate uniform random numbers from 1 to 10 using only rand7(), applying rejection sampling for consistent probability …

Medium
473

Matchsticks to Square

The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…

Medium
474

Ones and Zeroes

Solve the Ones and Zeroes problem using dynamic programming with state transition, focusing on array and string manipula…

Medium
475

Heaters

Determine the minimum heater radius to cover all houses using a binary search over potential radius values efficiently.

Medium
477

Total Hamming Distance

Calculate the total Hamming distance between all pairs in an integer array using efficient bit manipulation techniques.

Medium
478

Generate Random Point in a Circle

Generate Random Point in a Circle requires creating a uniform random point inside a circle using math and geometry princ…

Medium
481

Magical String

Count the number of '1's in the first n characters of a magical string using two-pointer scanning and invariant tracking…

Medium
486

Predict the Winner

Predict the Winner involves two players taking turns to maximize their score by picking from either end of an array, opt…

Medium
491

Non-decreasing Subsequences

Return all possible non-decreasing subsequences with at least two elements from the input array, nums.

Medium
494

Target Sum

Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…

Medium
497

Random Point in Non-overlapping Rectangles

Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.

Medium
498

Diagonal Traverse

Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.

Medium
503

Next Greater Element II

Solve the Next Greater Element II problem by using a stack-based state management approach for circular arrays.

Medium
508

Most Frequent Subtree Sum

Identify the most frequent subtree sum in a binary tree using DFS and hash table tracking for efficient state management…

Medium
513

Find Bottom Left Tree Value

Find the leftmost value in the last row of a binary tree using efficient traversal strategies.

Medium
515

Find Largest Value in Each Tree Row

Find the largest value in each row of a binary tree using depth-first or breadth-first search techniques.

Medium
516

Longest Palindromic Subsequence

Find the length of the longest palindromic subsequence in a string using precise state transition dynamic programming.

Medium
518

Coin Change II

Calculate the number of unique coin combinations to reach a target amount using state transition dynamic programming eff…

Medium
519

Random Flip Matrix

Design an optimized algorithm to randomly flip an index in a matrix, using hash tables and math for efficient random sel…

Medium
522

Longest Uncommon Subsequence II

Find the longest string in an array that is not a subsequence of any other string, using array scanning and hash checks …

Medium
523

Continuous Subarray Sum

Identify if any continuous subarray sums to a multiple of k using prefix sums and hash table tracking efficiently.

Medium
524

Longest Word in Dictionary through Deleting

Find the longest word in the dictionary that can be formed by deleting characters from a string, using two-pointer scann…

Medium
525

Contiguous Array

Find the maximum length contiguous subarray with equal numbers of 0s and 1s using array scanning and hash lookup efficie…

Medium
526

Beautiful Arrangement

The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…

Medium
528

Random Pick with Weight

Random Pick with Weight requires implementing a probabilistic index picker using prefix sums and binary search efficient…

Medium
529

Minesweeper

Solve the Minesweeper game by updating revealed squares and handling clicks with Depth-First Search and Array manipulati…

Medium
532

K-diff Pairs in an Array

Solve K-diff Pairs in an Array by counting unique differences with a hash map or sorted two-pointer sweep.

Medium
535

Encode and Decode TinyURL

Design a class that encodes and decodes URLs using a URL shortening approach based on hash tables and strings.

Medium
537

Complex Number Multiplication

This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…

Medium
538

Convert BST to Greater Tree

Convert a BST into a Greater Tree by updating each node’s value with the sum of all greater values in the tree.

Medium
539

Minimum Time Difference

Calculate the smallest time difference between clock points using array manipulation and mathematical conversions effici…

Medium
540

Single Element in a Sorted Array

Find the single non-duplicate element in a sorted array where every other element appears exactly twice.

Medium
542

01 Matrix

The '01 Matrix' problem challenges you to find the nearest zero for each cell in a binary matrix using dynamic programmi…

Medium
547

Number of Provinces

Solve Number of Provinces by scanning the adjacency matrix and launching DFS once per unvisited city component.

Medium
553

Optimal Division

Maximize the value of an expression by optimally placing parentheses for division operations.

Medium
554

Brick Wall

Solve the Brick Wall problem using array scanning and hash lookups to minimize crossed bricks from a vertical line.

Medium
556

Next Greater Element III

Find the next greater integer using the same digits as a given number with precise two-pointer scanning and invariant tr…

Medium
558

Logical OR of Two Binary Grids Represented as Quad-Trees

Compute the logical OR of two binary matrices represented as Quad-Trees using recursive tree traversal and state propaga…

Medium
560

Subarray Sum Equals K

Count the total number of contiguous subarrays in an integer array that sum exactly to a target value k using optimized …

Medium
565

Array Nesting

Find the longest nested set in a permutation array using a depth-first traversal, handling cycles efficiently for medium…

Medium
567

Permutation in String

Check if a string contains a permutation of another string using two-pointer scanning and hash table techniques.

Medium
576

Out of Boundary Paths

Calculate the number of ways a ball can exit a grid using dynamic programming with state transitions for every move comb…

Medium
581

Shortest Unsorted Continuous Subarray

Find the shortest unsorted continuous subarray that, if sorted, would sort the entire array.

Medium
583

Delete Operation for Two Strings

Find the minimum number of steps to make two strings equal by deleting characters, using dynamic programming.

Medium
592

Fraction Addition and Subtraction

Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…

Medium
593

Valid Square

Determine if four given 2D points form a valid square using geometric distance checks and vector validation techniques.

Medium
606

Construct String from Binary Tree

Given a binary tree, construct a string representation based on preorder traversal while adhering to specific formatting…

Medium
609

Find Duplicate File in System

Find and return duplicate files in the file system, grouping them by their paths and contents using an array scanning ap…

Medium
611

Valid Triangle Number

Count all triplets in an integer array that satisfy the triangle inequality to form valid triangles efficiently using so…

Medium
621

Task Scheduler

Task Scheduler is solved by counting task frequencies and computing how cooldown gaps force idle slots around the most f…

Medium
622

Design Circular Queue

Design a circular queue that allows efficient FIFO operations using linked-list pointer manipulation to optimize space u…

Medium
623

Add One Row to Tree

The problem requires adding a row of nodes to a binary tree at a specified depth.

Medium
624

Maximum Distance in Arrays

Maximum Distance in Arrays uses a greedy running minimum and maximum from previous arrays to validate cross array distan…

Medium
633

Sum of Square Numbers

Given a non-negative integer c, determine if there are two integers whose squares sum to c.

Medium
636

Exclusive Time of Functions

Solve the 'Exclusive Time of Functions' problem using stack-based state management for accurate function execution time …

Medium
638

Shopping Offers

Minimize the cost of purchasing items using available special offers with state transition dynamic programming.

Medium
640

Solve the Equation

Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.

Medium
641

Design Circular Deque

Design and implement a circular deque using linked-list pointer manipulation, ensuring efficient insertion and deletion …

Medium
646

Maximum Length of Pair Chain

Determine the maximum length of a chain formed by pairs using dynamic programming and greedy sorting techniques efficien…

Medium
647

Palindromic Substrings

Count all palindromic substrings in a given string using state transition dynamic programming for efficient evaluation.

Medium
648

Replace Words

Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…

Medium
649

Dota2 Senate

The Dota2 Senate problem involves simulating voting rounds between Radiant and Dire senators until one party wins, using…

Medium
650

2 Keys Keyboard

Minimize the number of operations to get exactly 'n' characters on the screen using two operations: Copy All and Paste.

Medium
652

Find Duplicate Subtrees

Identify all duplicate subtrees in a binary tree by efficiently tracking structure and values with depth-first traversal…

Medium
654

Maximum Binary Tree

Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …

Medium
655

Print Binary Tree

Print Binary Tree requires arranging a binary tree into a visually structured matrix using precise traversal and positio…

Medium
658

Find K Closest Elements

Identify the k integers closest to a target x in a sorted array using binary search and two-pointer strategies efficient…

Medium
659

Split Array into Consecutive Subsequences

Verify if it's possible to split a sorted array into consecutive subsequences of length 3 or more.

Medium
662

Maximum Width of Binary Tree

Determine the maximum width of a binary tree by calculating the width of each level and considering the positions of the…

Medium
665

Non-decreasing Array

Check if an array can become non-decreasing by modifying at most one element using an array-driven solution strategy.

Medium
667

Beautiful Arrangement II

Construct a beautiful arrangement of integers from 1 to n with k distinct integers, optimizing for time and space effici…

Medium
669

Trim a Binary Search Tree

Trim a Binary Search Tree by maintaining its structure while removing nodes outside a given range.

Medium
670

Maximum Swap

Given an integer, swap at most two digits once to produce the largest possible number using greedy digit selection.

Medium
672

Bulb Switcher II

Compute all unique bulb configurations after a fixed number of presses using math and bit manipulation efficiently.

Medium
673

Number of Longest Increasing Subsequence

This problem challenges you to find the number of longest increasing subsequences in a given array of integers.

Medium
676

Implement Magic Dictionary

Design a Magic Dictionary to allow searching with one-character modifications, using Hash Table and String techniques.

Medium
677

Map Sum Pairs

Design and implement a data structure that supports efficient insertion and sum queries based on string prefixes.

Medium
678

Valid Parenthesis String

Solve the Valid Parenthesis String problem by leveraging state transition dynamic programming to handle parentheses and …

Medium
684

Redundant Connection

Identify and remove the redundant edge that causes a cycle in a graph starting as a tree.

Medium
686

Repeated String Match

Find the minimum number of repetitions of string a to make string b a substring of the repeated string a.

Medium
687

Longest Univalue Path

Find the longest path in a binary tree where all nodes share the same value using depth-first search efficiently.

Medium
688

Knight Probability in Chessboard

Calculate the probability that a knight remains on an n x n chessboard after making exactly k moves using dynamic progra…

Medium
690

Employee Importance

Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…

Medium
692

Top K Frequent Words

Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…

Medium
695

Max Area of Island

Find the largest connected land area in a binary grid using array traversal and depth-first search efficiently.

Medium
698

Partition to K Equal Sum Subsets

Determine if an integer array can be partitioned into k subsets where each subset sums to the same value using DP and ba…

Medium
701

Insert into a Binary Search Tree

Insert a value into a Binary Search Tree while maintaining the BST properties, focusing on tree traversal and state trac…

Medium
707

Design Linked List

Implement a custom linked list supporting head, tail, index insertions, retrieval, and deletions efficiently with pointe…

Medium
712

Minimum ASCII Delete Sum for Two Strings

This problem focuses on minimizing the ASCII delete sum for two strings by using dynamic programming to find the lowest …

Medium
713

Subarray Product Less Than K

Count subarrays with a product strictly less than a given value k using efficient algorithms like binary search and slid…

Medium
714

Best Time to Buy and Sell Stock with Transaction Fee

Maximize stock trading profits accounting for per-transaction fees using state transition dynamic programming and greedy…

Medium
718

Maximum Length of Repeated Subarray

Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.

Medium
720

Longest Word in Dictionary

Find the longest word in a dictionary that can be built one character at a time from other words in the dictionary.

Medium
721

Accounts Merge

Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…

Medium
722

Remove Comments

Remove comments from a given C++ program source array, handling line and block comments.

Medium
725

Split Linked List in Parts

Efficiently split a singly linked list into k consecutive parts, balancing sizes while preserving the original node orde…

Medium
729

My Calendar I

Implement a calendar supporting non-overlapping event bookings using binary search for efficient insertion and conflict …

Medium
731

My Calendar II

Implement a calendar that allows double bookings but prevents triple bookings, managing overlapping intervals efficientl…

Medium
735

Asteroid Collision

Determine the final positions of moving asteroids using a stack-based simulation for efficient collision resolution in l…

Medium
738

Monotone Increasing Digits

Determine the largest number less than or equal to n with digits in non-decreasing order using a greedy, invariant-drive…

Medium
739

Daily Temperatures

In the Daily Temperatures problem, you need to find out how many days to wait for a warmer temperature based on given da…

Medium
740

Delete and Earn

Maximize points by deleting numbers from an array while removing all adjacent values, using dynamic programming efficien…

Medium
743

Network Delay Time

Find the minimum time for a signal to travel to all nodes in a directed graph or determine if it's impossible.

Medium
752

Open the Lock

Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.

Medium
754

Reach a Number

Determine the minimum number of moves to reach a target on an infinite number line using step increments, leveraging bin…

Medium
756

Pyramid Transition Matrix

The Pyramid Transition Matrix problem requires determining whether a pyramid can be formed with given blocks and valid p…

Medium
763

Partition Labels

Partition a string into maximal parts so that each letter appears in only one segment, using two-pointer scanning.

Medium
764

Largest Plus Sign

Find the largest axis-aligned plus sign in a binary grid with some mines using dynamic programming.

Medium
767

Reorganize String

Reorganize a string so that no two adjacent characters are the same, if possible, using a greedy approach.

Medium
769

Max Chunks To Make Sorted

The Max Chunks To Make Sorted problem requires you to split an array into the maximum number of chunks that can be sorte…

Medium
775

Global and Local Inversions

Determine if every global inversion in a permutation array is also a local inversion using array and math logic efficien…

Medium
777

Swap Adjacent in LR String

Transform one string into another by swapping adjacent 'L' and 'R' characters in a sequence of moves.

Medium
779

K-th Symbol in Grammar

Determine the K-th symbol in a recursively generated grammar table using math and bit manipulation patterns efficiently.

Medium
781

Rabbits in Forest

Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.

Medium
784

Letter Case Permutation

Letter Case Permutation involves generating all possible strings by changing the case of each letter in a given string.

Medium
785

Is Graph Bipartite?

Determine whether an undirected graph can be split into two independent sets using DFS, BFS, or Union Find patterns.

Medium
786

K-th Smallest Prime Fraction

Find the k-th smallest fraction from a sorted array of unique primes using a binary search over the answer space.

Medium
787

Cheapest Flights Within K Stops

Find the cheapest flight from a source to a destination with at most K stops using graph traversal techniques efficientl…

Medium
788

Rotated Digits

Count all integers from 1 to n that transform into a different valid number when each digit is rotated 180 degrees using…

Medium
789

Escape The Ghosts

Escape The Ghosts tests your ability to analyze movements in an infinite grid while racing against ghost positions using…

Medium
790

Domino and Tromino Tiling

Calculate the number of ways to tile a 2xN board using dominoes and trominoes with precise state transitions.

Medium
791

Custom Sort String

Sort the string `s` according to a custom order defined by string `order`.

Medium
792

Number of Matching Subsequences

Given a string s and a list of words, count how many words are subsequences of s using efficient array scanning and hash…

Medium
794

Valid Tic-Tac-Toe State

Verify if a given Tic-Tac-Toe board can represent a valid game state during a valid sequence of moves.

Medium
795

Number of Subarrays with Bounded Maximum

Count the number of contiguous subarrays with a bounded maximum value using a two-pointer approach.

Medium
797

All Paths From Source to Target

Find all paths in a directed acyclic graph (DAG) from source to target using depth-first search and backtracking.

Medium
799

Champagne Tower

Compute champagne levels in a pyramid of glasses using state transition dynamic programming for accurate distribution tr…

Medium
802

Find Eventual Safe States

Solve the problem of finding eventual safe states in a directed graph using depth-first search and topological sorting.

Medium
807

Max Increase to Keep City Skyline

Maximize building heights in a city grid without changing the skyline, using greedy selection constrained by row and col…

Medium
808

Soup Servings

Compute the probability that soup A empties before soup B using state transition dynamic programming efficiently.

Medium
809

Expressive Words

Expressive Words challenges you to determine if a word can be transformed into a given string by extending groups of rep…

Medium
811

Subdomain Visit Count

The Subdomain Visit Count problem requires counting the visits to all subdomains of a given domain from a list of count-…

Medium
813

Largest Sum of Averages

Maximize the sum of averages by partitioning an integer array into at most k contiguous subarrays using dynamic programm…

Medium
814

Binary Tree Pruning

Binary Tree Pruning removes subtrees not containing a 1, applying binary-tree traversal with state tracking.

Medium
816

Ambiguous Coordinates

Find all valid 2D coordinate possibilities for an ambiguous input string using backtracking and pruning techniques.

Medium
817

Linked List Components

Count the number of connected components in a linked list subset using array scanning and hash table lookups efficiently…

Medium
820

Short Encoding of Words

Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…

Medium
822

Card Flipping Game

The Card Flipping Game problem asks for the smallest integer that can be facing down but not up after flipping cards.

Medium
823

Binary Trees With Factors

Given an array of integers, find how many binary trees can be formed such that non-leaf nodes' values are the product of…

Medium
825

Friends Of Appropriate Ages

The Friends Of Appropriate Ages problem involves counting valid friend requests between people based on their ages with …

Medium
826

Most Profit Assigning Work

Assign workers to jobs maximizing total profit using difficulty, profit, and worker arrays efficiently with binary searc…

Medium
831

Masking Personal Information

This problem requires masking sensitive parts of emails and phone numbers using a precise string-driven strategy efficie…

Medium
833

Find And Replace in String

This problem challenges you to perform multiple string replacements at specific indices using a pattern involving array …

Medium
835

Image Overlap

Image Overlap requires calculating the overlap between two binary matrices by translating one image over the other.

Medium
837

New 21 Game

Calculate the probability Alice reaches at most n points using state transition dynamic programming efficiently.

Medium
838

Push Dominoes

In the "Push Dominoes" problem, you simulate the falling dominoes based on their initial states and determine their fina…

Medium
840

Magic Squares In Grid

Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.

Medium
841

Keys and Rooms

Determine if all rooms can be visited given keys distributed across a set of interconnected locked rooms using graph tra…

Medium
842

Split Array into Fibonacci Sequence

This problem challenges you to split a string into a Fibonacci-like sequence using backtracking and pruning.

Medium
845

Longest Mountain in Array

Find the length of the longest subarray forming a mountain pattern using state transitions and two-pointer logic efficie…

Medium
846

Hand of Straights

Check if a hand of cards can be rearranged into groups of consecutive values.

Medium
848

Shifting Letters

Given a string and a shift array, shift the first i+1 letters of the string as specified in the array.

Medium
849

Maximize Distance to Closest Person

Determine the seat placement that maximizes distance to the nearest person using a linear array scan strategy efficientl…

Medium
851

Loud and Rich

Determine the quietest person richer than each individual using graph indegree analysis and topological ordering techniq…

Medium
852

Peak Index in a Mountain Array

Find the peak index in a mountain array using binary search for efficient O(log n) time complexity.

Medium
853

Car Fleet

The Car Fleet problem asks how many car fleets will reach a target given their starting positions and speeds, considerin…

Medium
855

Exam Room

Simulate an exam room where each student chooses a seat maximizing distance to others, using design plus heap structures…

Medium
856

Score of Parentheses

Calculate the score of a balanced parentheses string using stack-based state management for an optimal solution.

Medium
858

Mirror Reflection

Given a square room with mirrors, find which receptor a laser ray will hit first based on two integers, p and q.

Medium
861

Score After Flipping Matrix

Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.

Medium
863

All Nodes Distance K in Binary Tree

Find all nodes at distance K from a target node in a binary tree using various tree traversal techniques.

Medium
865

Smallest Subtree with all the Deepest Nodes

Find the smallest subtree that contains all the deepest nodes in a binary tree.

Medium
866

Prime Palindrome

The Prime Palindrome problem asks for the smallest prime palindrome greater than or equal to a given integer.

Medium
869

Reordered Power of 2

Determine if a number's digits can be rearranged to form a power of two using counting and hash-based checks.

Medium
870

Advantage Shuffle

Maximize the advantage of nums1 over nums2 using a two-pointer greedy strategy, carefully tracking which elements beat o…

Medium
873

Length of Longest Fibonacci Subsequence

Find the length of the longest Fibonacci-like subsequence from a strictly increasing array of integers.

Medium
874

Walking Robot Simulation

The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…

Medium
875

Koko Eating Bananas

Koko Eating Bananas challenges you to find the minimum eating speed to finish piles of bananas in a given time using bin…

Medium
877

Stone Game

Stone Game is a dynamic programming problem where players alternate taking stones from piles to maximize their score.

Medium
880

Decoded String at Index

Decode the string and find the k-th letter efficiently using stack-based state management in this problem.

Medium
881

Boats to Save People

Find the minimum number of boats required to save all people, using a two-pointer approach for efficient pairing.

Medium
885

Spiral Matrix III

Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…

Medium
886

Possible Bipartition

Determine if a group of n people with mutual dislikes can be split into two non-conflicting groups using graph traversal…

Medium
889

Construct Binary Tree from Preorder and Postorder Traversal

Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.

Medium
890

Find and Replace Pattern

Identify all words matching a given pattern by checking consistent letter mappings using hash tables and array scanning …

Medium
893

Groups of Special-Equivalent Strings

Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.

Medium
894

All Possible Full Binary Trees

Generate all possible full binary trees with n nodes, focusing on dynamic programming and binary tree traversal.

Medium
898

Bitwise ORs of Subarrays

Compute the number of unique bitwise OR values from all non-empty subarrays using dynamic state transitions efficiently.

Medium
900

RLE Iterator

Design an efficient iterator for a run-length encoded array, handling large counts and sequential access correctly every…

Medium
901

Online Stock Span

Design an efficient algorithm using stacks to calculate the stock span for daily price quotes.

Medium
904

Fruit Into Baskets

The Fruit Into Baskets problem requires finding the maximum number of fruits you can pick from a row of trees under spec…

Medium
907

Sum of Subarray Minimums

Calculate the sum of minimum values across all subarrays of a given array modulo 10^9 + 7.

Medium
909

Snakes and Ladders

Solve the Snakes and Ladders problem using a BFS strategy to efficiently navigate the board and reach the final square.

Medium
910

Smallest Range II

Determine the minimum possible difference between the largest and smallest numbers after adjusting each by plus or minus…

Medium
911

Online Election

Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…

Medium
912

Sort an Array

Sort an array using an optimal algorithm, focusing on time and space complexity considerations.

Medium
915

Partition Array into Disjoint Intervals

Partition the array into two subarrays such that the left contains the smallest possible elements and the right contains…

Medium
916

Word Subsets

Word Subsets is solved by merging words2 into one max-frequency requirement, then scanning words1 against that fixed let…

Medium
918

Maximum Sum Circular Subarray

Find the maximum sum of a circular subarray using state transition dynamic programming, optimizing for wraparound cases …

Medium
919

Complete Binary Tree Inserter

Implement a data structure to insert nodes into a complete binary tree while preserving its completeness efficiently.

Medium
921

Minimum Add to Make Parentheses Valid

Compute the minimum insertions needed to make a parentheses string valid using efficient stack-based state tracking tech…

Medium
923

3Sum With Multiplicity

Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…

Medium
926

Flip String to Monotone Increasing

Minimize the number of flips needed to make a binary string monotone increasing using dynamic programming.

Medium
930

Binary Subarrays With Sum

Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…

Medium
931

Minimum Falling Path Sum

Minimum Falling Path Sum is a matrix dynamic programming problem where each cell depends on three reachable cells above …

Medium
932

Beautiful Array

Beautiful Array builds a valid permutation by recursively separating odd and even positions so no middle-average triple …

Medium
934

Shortest Bridge

Find the minimum flips to connect two separate islands in a binary matrix using Array and DFS techniques efficiently.

Medium
935

Knight Dialer

Solve the Knight Dialer problem using state transition dynamic programming to efficiently calculate valid number paths f…

Medium
937

Reorder Data in Log Files

Reorder Data in Log Files requires sorting letter-logs lexicographically while keeping digit-logs in original order for …

Medium
939

Minimum Area Rectangle

Find the minimum area of a rectangle formed by given points on a 2D plane with sides parallel to axes.

Medium
945

Minimum Increment to Make Array Unique

This problem challenges you to find the minimum moves to make all elements in an array unique by incrementing elements.

Medium
946

Validate Stack Sequences

Determine if a sequence of push and pop operations can produce the given popped array using a stack-based state approach…

Medium
947

Most Stones Removed with Same Row or Column

Maximize the number of stones removed from a 2D plane using graph traversal and DFS.

Medium
948

Bag of Tokens

Maximize your score in the Bag of Tokens problem by strategically playing tokens with two-pointer scanning and greedy te…

Medium
949

Largest Time for Given Digits

Given four digits, determine the latest valid 24-hour time possible using each digit exactly once with backtracking.

Medium
950

Reveal Cards In Increasing Order

Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.

Medium
951

Flip Equivalent Binary Trees

Determine if two binary trees are flip equivalent by recursively swapping subtrees.

Medium
954

Array of Doubled Pairs

Given an array of even length, check if it can be reordered to satisfy a specific doubling condition.

Medium
955

Delete Columns to Make Sorted II

Solve the "Delete Columns to Make Sorted II" problem by applying greedy choices and invariant validation to string array…

Medium
957

Prison Cells After N Days

Determine the state of 8 prison cells after N days using array scanning and cycle detection for repeated patterns effici…

Medium
958

Check Completeness of a Binary Tree

Determine if a binary tree is complete by verifying its node structure and leftmost placement in the last level.

Medium
959

Regions Cut By Slashes

Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.

Medium
962

Maximum Width Ramp

Find the maximum width of a ramp where nums[i] <= nums[j] for i < j using a two-pointer approach.

Medium
963

Minimum Area Rectangle II

Find the minimum area rectangle from given points in the X-Y plane, with sides not necessarily parallel to the axes.

Medium
966

Vowel Spellchecker

Implement a spellchecker that matches queries to a wordlist using exact, case-insensitive, and vowel-error rules efficie…

Medium
967

Numbers With Same Consecutive Differences

Generate all n-digit numbers where consecutive digits differ by k using efficient backtracking and BFS techniques.

Medium
969

Pancake Sorting

Sort an array using pancake flips, leveraging two-pointer scanning and invariant tracking to iteratively position the la…

Medium
970

Powerful Integers

Find all integers that can be expressed as x^i + y^j up to a given bound using a Hash Table plus Math approach.

Medium
971

Flip Binary Tree To Match Preorder Traversal

Determine the minimum set of nodes to flip in a binary tree so its pre-order traversal matches a given voyage sequence.

Medium
973

K Closest Points to Origin

Find the k closest points to the origin in a 2D plane using array operations and Euclidean distance calculations efficie…

Medium
974

Subarray Sums Divisible by K

Count the number of subarrays whose sum is divisible by a given integer k using array scanning and hash lookup.

Medium
978

Longest Turbulent Subarray

Find the length of the longest subarray where element comparisons alternate, using state transition dynamic programming …

Medium
979

Distribute Coins in Binary Tree

Minimize the number of moves needed to distribute coins in a binary tree so that each node has exactly one coin.

Medium
981

Time Based Key-Value Store

Implement a time-based key-value store that retrieves the latest value at a given timestamp using efficient binary searc…

Medium
983

Minimum Cost For Tickets

Solve the Minimum Cost For Tickets problem using state transition dynamic programming for optimal travel ticket purchase…

Medium
984

String Without AAA or BBB

Solve the problem of constructing a string without consecutive 'AAA' or 'BBB' by applying a greedy approach with invaria…

Medium
985

Sum of Even Numbers After Queries

Efficiently update an integer array based on queries and compute the sum of even numbers after each modification using s…

Medium
986

Interval List Intersections

This problem requires finding the intersection of two lists of intervals using a two-pointer technique with invariant tr…

Medium
988

Smallest String Starting From Leaf

Determine the lexicographically smallest string from a leaf to root using binary-tree traversal and careful state tracki…

Medium
990

Satisfiability of Equality Equations

Determine if it's possible to assign values to variables such that all equations are satisfied based on equality and ine…

Medium
991

Broken Calculator

Compute the minimum operations to transform startValue into target using doubling and decrementing, leveraging a greedy …

Medium
994

Rotting Oranges

Given a grid with fresh and rotten oranges, return the minimum time for all oranges to rot or -1 if impossible.

Medium
998

Maximum Binary Tree II

The Maximum Binary Tree II problem requires building a binary tree by inserting a value into a maximum binary tree while…

Medium
1003

Check If Word Is Valid After Substitutions

Determine if a string can be built from repeated 'abc' insertions using stack-based state management, verifying sequence…

Medium
1004

Max Consecutive Ones III

Find the longest consecutive ones in a binary array by optimally flipping at most k zeros using sliding window technique…

Medium
1006

Clumsy Factorial

Compute the clumsy factorial of a number using a fixed rotation of multiply, divide, add, and subtract operations effici…

Medium
1007

Minimum Domino Rotations For Equal Row

Minimize domino rotations to make either row identical in the problem of Minimum Domino Rotations For Equal Row.

Medium
1008

Construct Binary Search Tree from Preorder Traversal

Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.

Medium
1010

Pairs of Songs With Total Durations Divisible by 60

Calculate the number of song pairs whose total durations sum to a multiple of 60 using array scanning and hash lookups.

Medium
1011

Capacity To Ship Packages Within D Days

Find the minimum ship capacity needed to ship all packages within D days, ensuring the cargo is shipped in the given ord…

Medium
1014

Best Sightseeing Pair

Compute the maximum sightseeing score efficiently using state transition dynamic programming and single-pass array itera…

Medium
1015

Smallest Integer Divisible by K

Find the length of the smallest positive integer divisible by k that consists only of the digit '1'.

Medium
1016

Binary String With Substrings Representing 1 To N

Check if binary string contains all integers from 1 to n as substrings, leveraging sliding window and bit manipulation t…

Medium
1017

Convert to Base -2

Convert any non-negative integer into its base -2 representation using a math-driven iterative remainder strategy.

Medium
1019

Next Greater Node In Linked List

Find the next greater value for each node in a linked list using monotonic stack techniques for efficient traversal.

Medium
1020

Number of Enclaves

This problem involves finding the number of land cells that cannot reach the boundary in a grid using DFS and array mani…

Medium
1023

Camelcase Matching

Camelcase Matching is a medium difficulty problem where you match queries to a given pattern by inserting lowercase lett…

Medium
1024

Video Stitching

Solve the "Video Stitching" problem using state transition dynamic programming to cover a sporting event with minimum cl…

Medium
1026

Maximum Difference Between Node and Ancestor

Find the maximum absolute difference between a node and its ancestor in a binary tree.

Medium
1027

Longest Arithmetic Subsequence

Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.

Medium
1029

Two City Scheduling

Two City Scheduling requires selecting optimal city assignments for 2n people to minimize total travel costs efficiently…

Medium
1031

Maximum Sum of Two Non-Overlapping Subarrays

Find the maximum sum of two non-overlapping subarrays by efficiently using state transition dynamic programming.

Medium
1033

Moving Stones Until Consecutive

Solve the "Moving Stones Until Consecutive" problem using math and brainteaser patterns by determining the minimum and m…

Medium
1034

Coloring A Border

Given a grid and a starting cell, color all border cells of the connected component using DFS while preserving interior …

Medium
1035

Uncrossed Lines

The Uncrossed Lines problem involves finding the maximum number of non-intersecting lines that can be drawn between two …

Medium
1038

Binary Search Tree to Greater Sum Tree

Convert a Binary Search Tree to a Greater Sum Tree by accumulating all larger node values using reverse in-order travers…

Medium
1039

Minimum Score Triangulation of Polygon

Compute the minimum total score to triangulate a convex polygon using state transition dynamic programming on vertex val…

Medium
1040

Moving Stones Until Consecutive II

Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…

Medium
1041

Robot Bounded In Circle

Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…

Medium
1042

Flower Planting With No Adjacent

In this problem, you are tasked with planting flowers in gardens with specific constraints based on graph traversal prin…

Medium
1043

Partition Array for Maximum Sum

Partition an array into subarrays of length at most k, replacing each with its maximum to maximize total sum efficiently…

Medium
1048

Longest String Chain

Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…

Medium
1049

Last Stone Weight II

In the 'Last Stone Weight II' problem, you need to find the minimal possible stone weight after a series of smashes usin…

Medium
1052

Grumpy Bookstore Owner

Maximize satisfied customers in a bookstore by strategically suppressing the owner's grumpy minutes using a sliding wind…

Medium
1053

Previous Permutation With One Swap

Find the lexicographically largest permutation smaller than the given array using exactly one swap, leveraging a greedy …

Medium
1054

Distant Barcodes

Rearrange barcodes in an array so that no two adjacent elements are equal, using a greedy approach and hash table for ef…

Medium
1061

Lexicographically Smallest Equivalent String

Determine the lexicographically smallest string by modeling character equivalences with union find efficiently.

Medium
1072

Flip Columns For Maximum Number of Equal Rows

Maximize the number of equal rows in a binary matrix by flipping any number of columns.

Medium
1073

Adding Two Negabinary Numbers

Add two numbers represented in negabinary format and return the result in the same format.

Medium
1079

Letter Tile Possibilities

Compute all unique non-empty sequences from given letter tiles using backtracking search with pruning efficiently.

Medium
1080

Insufficient Nodes in Root to Leaf Paths

Remove nodes in a binary tree whose all root-to-leaf paths sum to less than a given limit using DFS traversal and state …

Medium
1081

Smallest Subsequence of Distinct Characters

The Smallest Subsequence of Distinct Characters problem asks you to find the lexicographically smallest subsequence of a…

Medium
1090

Largest Values From Labels

Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.

Medium
1091

Shortest Path in Binary Matrix

Find the shortest clear path in a binary matrix using BFS, carefully handling obstacles and diagonal movements for effic…

Medium
1093

Statistics from a Large Sample

Calculate minimum, maximum, mean, median, and mode from a large sample represented by an array of counts.

Medium
1094

Car Pooling

Determine if a car can handle multiple trips without exceeding its capacity using array sorting and event simulation tec…

Medium
1104

Path In Zigzag Labelled Binary Tree

The problem involves finding the path from the root to a node in a zigzag-labelled binary tree.

Medium
1105

Filling Bookcase Shelves

Determine the minimum total height of a bookcase by placing books in order using state transition dynamic programming.

Medium
1109

Corporate Flight Bookings

Solve Corporate Flight Bookings by marking range changes once, then building final seat totals with a single prefix sum …

Medium
1110

Delete Nodes And Return Forest

Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.

Medium
1111

Maximum Nesting Depth of Two Valid Parentheses Strings

This problem challenges you to compute the maximum nesting depth of two valid parentheses strings using stack-based stat…

Medium
1123

Lowest Common Ancestor of Deepest Leaves

Find the lowest common ancestor of the deepest leaves in a binary tree using efficient traversal and state tracking tech…

Medium
1124

Longest Well-Performing Interval

The Longest Well-Performing Interval problem challenges you to find the longest subarray where tiring days exceed non-ti…

Medium
1129

Shortest Path with Alternating Colors

Solve the shortest path problem with alternating edge colors using graph traversal and BFS.

Medium
1130

Minimum Cost Tree From Leaf Values

Compute the minimum sum of non-leaf nodes in a binary tree formed from array leaves using dynamic programming efficientl…

Medium
1131

Maximum of Absolute Value Expression

Calculate the largest sum of absolute differences across two arrays and their indices using an efficient pattern-based a…

Medium
1138

Alphabet Board Path

Find the path to type a target string on an alphabet board using directional moves and the 'hash table plus string' patt…

Medium
1139

Largest 1-Bordered Square

Find the largest square of 1s with 1s on its borders in a binary grid using dynamic programming.

Medium
1140

Stone Game II

Stone Game II is a dynamic programming problem where Alice and Bob alternate taking stones from piles to maximize their …

Medium
1143

Longest Common Subsequence

Find the length of the longest common subsequence between two strings using state transition dynamic programming for eff…

Medium
1144

Decrease Elements To Make Array Zigzag

Transform any integer array into a zigzag pattern with minimal decrements using a targeted greedy approach and invariant…

Medium
1145

Binary Tree Coloring Game

A two-player game where players color nodes in a binary tree, aiming to outmaneuver each other by choosing adjacent node…

Medium
1146

Snapshot Array

Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…

Medium
1155

Number of Dice Rolls With Target Sum

Calculate the number of ways to roll n dice with k faces to reach a target sum using state transition dynamic programmin…

Medium
1156

Swap For Longest Repeated Character Substring

Find the maximum length of a repeated character substring after swapping two characters using a sliding window approach …

Medium
1161

Maximum Level Sum of a Binary Tree

Find the level of a binary tree where the sum of its nodes is maximal, with an emphasis on binary-tree traversal.

Medium
1162

As Far from Land as Possible

Find the farthest water cell from land in a grid and return the Manhattan distance using state transition dynamic progra…

Medium
1169

Invalid Transactions

Detect invalid transactions by scanning arrays and cross-checking with hash tables for time, amount, and city conflicts …

Medium
1170

Compare Strings by Frequency of the Smallest Character

Compare Strings by Frequency of the Smallest Character requires counting minimal character frequencies in words and quer…

Medium
1171

Remove Zero Sum Consecutive Nodes from Linked List

Remove zero-sum consecutive nodes from a linked list by iterating through it, repeatedly deleting sequences that sum to …

Medium
1177

Can Make Palindrome from Substring

Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.

Medium
1186

Maximum Subarray Sum with One Deletion

Find the maximum sum of a subarray with at most one deletion in this dynamic programming problem.

Medium
1190

Reverse Substrings Between Each Pair of Parentheses

Reverse all substrings within matched parentheses using a stack-based approach for efficient state tracking and reversal…

Medium
1191

K-Concatenation Maximum Sum

Solve the K-Concatenation Maximum Sum problem using dynamic programming and optimal sub-array sum calculation.

Medium
1201

Ugly Number III

Find the nth positive integer divisible by a, b, or c using binary search over the answer space efficiently and accurate…

Medium
1202

Smallest String With Swaps

Find the lexicographically smallest string by swapping characters in given pairs of indices.

Medium
1208

Get Equal Substrings Within Budget

Optimize substring transformations using a binary search approach to maximize the change within a budget.

Medium
1209

Remove All Adjacent Duplicates in String II

Remove all adjacent duplicates in the string using stack-based state management with a given threshold k.

Medium
1218

Longest Arithmetic Subsequence of Given Difference

Find the longest arithmetic subsequence with a given difference using dynamic programming and hash tables.

Medium
1219

Path with Maximum Gold

Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.

Medium
1222

Queens That Can Attack the King

Identify all black queens on an 8x8 chessboard that can attack the white king using array and matrix simulation techniqu…

Medium
1227

Airplane Seat Assignment Probability

Calculate the probability that the last passenger sits in their assigned seat using state transition dynamic programming…

Medium
1233

Remove Sub-Folders from the Filesystem

Remove sub-folders in a filesystem by filtering out folders nested inside other folders.

Medium
1234

Replace the Substring for Balanced String

Determine the minimum substring length to replace in order to balance a string of Q, W, E, and R characters efficiently.

Medium
1237

Find Positive Integer Solution for a Given Equation

Determine all positive integer pairs that satisfy a hidden monotonic function for a given target using binary search ove…

Medium
1238

Circular Permutation in Binary Representation

Generate a circular permutation from a range of numbers using backtracking and bit manipulation.

Medium
1239

Maximum Length of a Concatenated String with Unique Characters

Find the maximum length of a concatenated string from an array with all unique characters using backtracking search with…

Medium
1247

Minimum Swaps to Make Strings Equal

This problem requires determining the minimum number of swaps to make two strings equal by swapping characters between t…

Medium
1248

Count Number of Nice Subarrays

The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.

Medium
1249

Minimum Remove to Make Valid Parentheses

Given a string with parentheses and letters, remove the fewest parentheses to produce any valid balanced string efficien…

Medium
1253

Reconstruct a 2-Row Binary Matrix

Reconstruct a 2-row binary matrix by distributing column sums while respecting upper and lower row limits using greedy p…

Medium
1254

Number of Closed Islands

Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.

Medium
1261

Find Elements in a Contaminated Binary Tree

Recover values in a contaminated binary tree and efficiently check for existence using traversal and state tracking tech…

Medium
1262

Greatest Sum Divisible by Three

Find the maximum sum divisible by three from a given array using dynamic programming and state transition.

Medium
1267

Count Servers that Communicate

Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…

Medium
1268

Search Suggestions System

Design a search suggestion system that provides the top three lexicographically smallest products matching a search word…

Medium
1276

Number of Burgers with No Waste of Ingredients

Determine the exact counts of jumbo and small burgers using all tomato and cheese slices without leftovers, applying mat…

Medium
1277

Count Square Submatrices with All Ones

Count the number of square submatrices with all ones in a given binary matrix using dynamic programming.

Medium
1282

Group the People Given the Group Size They Belong To

Organize people into groups based on their specified group sizes using array scanning and hash table bucketing efficient…

Medium
1283

Find the Smallest Divisor Given a Threshold

Find the smallest divisor such that the sum of all divided array elements is less than or equal to the threshold.

Medium
1286

Iterator for Combination

Implement an iterator that generates all combinations of a given length using efficient backtracking with pruning.

Medium
1288

Remove Covered Intervals

Remove all intervals fully covered by another using sorting and linear traversal, counting only distinct remaining inter…

Medium
1291

Sequential Digits

Find all integers within a range whose digits form a strictly increasing consecutive sequence using enumeration techniqu…

Medium
1292

Maximum Side Length of a Square with Sum Less than or Equal to Threshold

This problem challenges you to find the largest square in a matrix with a sum below a given threshold using binary searc…

Medium
1296

Divide Array in Sets of K Consecutive Numbers

Determine if an integer array can be partitioned into sets of k consecutive numbers using array scanning and hash mappin…

Medium
1297

Maximum Number of Occurrences of a Substring

Find the maximum number of occurrences of any valid substring in a given string with specific constraints on letter coun…

Medium
1300

Sum of Mutated Array Closest to Target

Find the integer that mutates all larger elements in an array to minimize the sum difference to a target efficiently.

Medium
1302

Deepest Leaves Sum

Find the sum of the deepest leaves in a binary tree by using tree traversal and state tracking techniques.

Medium
1305

All Elements in Two Binary Search Trees

Merge elements from two binary search trees and return them sorted in ascending order.

Medium
1306

Jump Game III

Jump Game III challenges you to determine if you can reach any zero in an array using jumps defined by array values, tes…

Medium
1310

XOR Queries of a Subarray

Compute XOR results for multiple subarray queries using efficient prefix XOR to reduce repeated computation overhead in …

Medium
1311

Get Watched Videos by Your Friends

Find videos watched by friends up to a given level and return them sorted by frequency and alphabetically.

Medium
1314

Matrix Block Sum

Compute a matrix where each cell contains the sum of all elements within k-distance blocks using prefix sums efficiently…

Medium
1315

Sum of Nodes with Even-Valued Grandparent

This problem involves calculating the sum of nodes with an even-valued grandparent in a binary tree.

Medium
1318

Minimum Flips to Make a OR b Equal to c

Determine the minimum number of bit flips required in two integers so that their OR equals a target integer efficiently.

Medium
1319

Number of Operations to Make Network Connected

Determine the minimum number of operations required to connect all computers in a network with a limited number of cable…

Medium
1324

Print Words Vertically

Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…

Medium
1325

Delete Leaves With a Given Value

In this problem, you need to delete all leaf nodes in a binary tree with a given target value, performing continuous del…

Medium
1328

Break a Palindrome

Given a palindrome, change exactly one character to make it non-palindromic and lexicographically smallest using a greed…

Medium
1329

Sort the Matrix Diagonally

Sort each diagonal of a matrix in ascending order, applying sorting and matrix traversal techniques.

Medium
1333

Filter Restaurants by Vegan-Friendly, Price and Distance

Filter restaurants by vegan-friendly status, price, and distance, and sort them by rating and ID.

Medium
1334

Find the City With the Smallest Number of Neighbors at a Threshold Distance

Find the city with the fewest neighbors within a given threshold distance using dynamic programming.

Medium
1338

Reduce Array Size to The Half

This problem asks to minimize the set of integers removed to reduce an array's size to at least half by removing occurre…

Medium
1339

Maximum Product of Splitted Binary Tree

Maximize the product of sums of two subtrees formed by splitting a binary tree.

Medium
1343

Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold

Given an array, find the number of sub-arrays of size k with an average greater than or equal to a given threshold.

Medium
1344

Angle Between Hands of a Clock

Calculate the smaller angle between the hour and minute hands of a clock based on given time inputs.

Medium
1347

Minimum Number of Steps to Make Two Strings Anagram

Calculate the minimum steps to transform one string into an anagram of another using character replacements efficiently.

Medium
1348

Tweet Counts Per Frequency

Design an efficient solution to track and retrieve tweet counts over different frequencies using binary search and hash …

Medium
1352

Product of the Last K Numbers

Design a data structure to efficiently return the product of the last k numbers in a dynamic integer stream using prefix…

Medium
1353

Maximum Number of Events That Can Be Attended

Maximize the number of events you can attend given their start and end days using a greedy strategy.

Medium
1357

Apply Discount Every n Orders

Compute customer bills with periodic discounts efficiently using array scanning and hash mapping for fast product price …

Medium
1358

Number of Substrings Containing All Three Characters

Count all substrings containing at least one of each character a, b, and c using a sliding window approach efficiently.

Medium
1361

Validate Binary Tree Nodes

Validate Binary Tree Nodes problem requires checking if a set of nodes forms a valid binary tree using graph traversal.

Medium
1362

Closest Divisors

Find the closest divisors of num + 1 and num + 2 with minimal absolute difference in this math-driven problem.

Medium
1366

Rank Teams by Votes

Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…

Medium
1367

Linked List in Binary Tree

Determine if a linked list is represented as a downward path in a binary tree using pointer traversal and recursive chec…

Medium
1371

Find the Longest Substring Containing Vowels in Even Counts

Find the longest substring with even counts of vowels using bitmasking and hash tables.

Medium
1372

Longest ZigZag Path in a Binary Tree

Find the longest ZigZag path in a binary tree using depth-first search and dynamic programming for precise node state tr…

Medium
1375

Number of Times Binary String Is Prefix-Aligned

Count how many times a 1-indexed binary string becomes prefix-aligned as bits are flipped sequentially using an array-dr…

Medium
1376

Time Needed to Inform All Employees

Calculate the time needed for the head of a company to inform all employees using tree traversal techniques.

Medium
1381

Design a Stack With Increment Operation

Implement a stack that supports push, pop, and targeted increment operations efficiently using array-based state managem…

Medium
1382

Balance a Binary Search Tree

This problem requires balancing a binary search tree using in-order traversal and state tracking techniques.

Medium
1386

Cinema Seat Allocation

Determine the maximum number of four-person groups that can be seated in a cinema using array scanning and hash lookup e…

Medium
1387

Sort Integers by The Power Value

Sort integers in a range based on their power value using dynamic programming and memoization, handling ties with ascend…

Medium
1390

Four Divisors

Compute the sum of all divisors for numbers in an array that have exactly four divisors using array and math techniques.

Medium
1391

Check if There is a Valid Path in a Grid

Check if there is a valid path from the upper-left to the bottom-right corner of a grid using depth-first search.

Medium
1395

Count Number of Teams

Count the number of valid three-soldier teams using ratings with a state transition dynamic programming approach efficie…

Medium
1396

Design Underground System

Design an underground system to calculate travel times between stations using hash tables for efficient lookups and aver…

Medium
1400

Construct K Palindrome Strings

Determine if a string's characters can be rearranged to form exactly k non-empty palindrome strings using greedy validat…

Medium
1401

Circle and Rectangle Overlapping

Determine if a circle intersects with an axis-aligned rectangle using geometric distance checks efficiently in code.

Medium
1404

Number of Steps to Reduce a Number in Binary Representation to One

Determine the number of steps to reduce a binary representation of a number to 1 by following specific rules.

Medium
1405

Longest Happy String

Solve the "Longest Happy String" problem using a greedy approach with validation of invariants for constructing the long…

Medium
1409

Queries on a Permutation With Key

This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.

Medium
1410

HTML Entity Parser

Transform a string containing HTML entities into their character equivalents using a hash table for efficient parsing.

Medium
1414

Find the Minimum Number of Fibonacci Numbers Whose Sum Is K

Find the minimum number of Fibonacci numbers that sum up to a given integer k, using a greedy approach.

Medium
1415

The k-th Lexicographical String of All Happy Strings of Length n

Given n and k, find the k-th lexicographical happy string of length n using backtracking search with pruning.

Medium
1418

Display Table of Food Orders in a Restaurant

Generate a restaurant display table from orders by counting each food item per table using array scanning and hash looku…

Medium
1419

Minimum Number of Frogs Croaking

Determine the minimum number of frogs required to sequentially produce all croaks in a mixed frog croak string efficient…

Medium
1423

Maximum Points You Can Obtain from Cards

Maximize your score by selecting k cards from the beginning or end of the array using a sliding window approach.

Medium
1424

Diagonal Traverse II

Traverse a jagged 2D array diagonally by grouping elements with equal row and column sums efficiently using sorting and …

Medium
1432

Max Difference You Can Get From Changing an Integer

Compute the maximum difference from changing digits in an integer using greedy choices and invariant checks efficiently.

Medium
1433

Check If a String Can Break Another String

This problem checks whether one string can break another using permutations and a greedy approach for comparison.

Medium
1438

Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit

Find the longest subarray with elements whose absolute difference is within a specified limit using a sliding window app…

Medium
1441

Build an Array With Stack Operations

Simulate stack operations to match a target array while processing numbers from 1 to n.

Medium
1442

Count Triplets That Can Form Two Arrays of Equal XOR

Efficiently count all triplets in an array where two subarrays formed by splitting have equal XOR using array scanning a…

Medium
1443

Minimum Time to Collect All Apples in a Tree

Minimize the time spent to collect all apples in a tree, considering traversal and state tracking with binary tree techn…

Medium
1447

Simplified Fractions

Generate simplified fractions between 0 and 1 with denominators up to a given integer n.

Medium
1448

Count Good Nodes in Binary Tree

Count Good Nodes in Binary Tree identifies nodes exceeding all previous values along their path using DFS traversal tech…

Medium
1451

Rearrange Words in a Sentence

Rearrange words in a sentence by their length, maintaining original order for words of equal size for consistent output.

Medium
1452

People Whose List of Favorite Companies Is Not a Subset of Another List

Identify people whose favorite companies lists are unique and not subsets of any other person's list using efficient arr…

Medium
1456

Maximum Number of Vowels in a Substring of Given Length

Find the maximum number of vowels in a substring of a given length in a string using a sliding window approach.

Medium
1457

Pseudo-Palindromic Paths in a Binary Tree

Count all root-to-leaf paths in a binary tree that can be rearranged to form a palindrome using bitwise state tracking.

Medium
1461

Check If a String Contains All Binary Codes of Size K

Determine if every possible binary string of length k exists as a substring within a given binary string s efficiently u…

Medium
1462

Course Schedule IV

Determine if one course is a prerequisite of another using graph indegree tracking and topological ordering efficiently.

Medium
1465

Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

Maximize the area of a piece of cake after specified horizontal and vertical cuts using greedy algorithms and sorting.

Medium
1466

Reorder Routes to Make All Paths Lead to the City Zero

Reorder Routes to Make All Paths Lead to the City Zero involves reversing the direction of roads in a tree to ensure all…

Medium
1471

The k Strongest Values in an Array

Identify the k strongest values in an array using two-pointer scanning and careful tracking of the array's centre value.

Medium
1472

Design Browser History

Implement a browser history tracker with back, forward, and visit operations using linked-list pointer manipulation effi…

Medium
1476

Subrectangle Queries

Implement the SubrectangleQueries class to handle dynamic updates and value queries on a 2D rectangle.

Medium
1477

Find Two Non-overlapping Sub-arrays Each With Target Sum

Find two non-overlapping sub-arrays with a given target sum and return the minimal total length efficiently using array …

Medium
1481

Least Number of Unique Integers after K Removals

Find the least number of unique integers after removing exactly k elements from an array using efficient frequency count…

Medium
1482

Minimum Number of Days to Make m Bouquets

Determine the minimum number of days required to make m bouquets using k adjacent flowers efficiently with binary search…

Medium
1487

Making File Names Unique

This problem requires creating unique folder names by appending suffixes to duplicate names using an array scanning and …

Medium
1488

Avoid Flood in The City

This problem asks you to avoid flooding by deciding when to dry lakes between rain events.

Medium
1492

The kth Factor of n

Find the kth factor of n by scanning divisors carefully or using factor pairs to skip unnecessary checks.

Medium
1493

Longest Subarray of 1's After Deleting One Element

Solve LeetCode 1493 by tracking runs of 1s around one deletion using a tight sliding window or state transition DP.

Medium
1497

Check If Array Pairs Are Divisible by k

Check if array pairs are divisible by k by pairing elements whose sums are divisible by k using array scanning and hash …

Medium
1498

Number of Subsequences That Satisfy the Given Sum Condition

Count all non-empty subsequences in an integer array where the sum of the minimum and maximum elements is at most a targ…

Medium
1503

Last Moment Before All Ants Fall Out of a Plank

This problem involves simulating ant movement on a plank to determine the last moment before all ants fall off.

Medium
1504

Count Submatrices With All Ones

Count Submatrices With All Ones is a dynamic programming problem focusing on submatrix counting using an efficient row-b…

Medium
1508

Range Sum of Sorted Subarray Sums

Compute the sum of sorted subarray sums efficiently using binary search over valid sum ranges and prefix sum accumulatio…

Medium
1509

Minimum Difference Between Largest and Smallest Value in Three Moves

Find the minimum difference between the largest and smallest values in an array after performing at most three moves.

Medium
1513

Number of Substrings With Only 1s

Calculate the number of contiguous substrings containing only 1s in a binary string using a math and string approach eff…

Medium
1514

Path with Maximum Probability

Find the path with the highest success probability in a graph from a start node to an end node, using edge probabilities…

Medium
1519

Number of Nodes in the Sub-Tree With the Same Label

Compute the number of nodes in each subtree sharing the same label using DFS with hash table aggregation efficiently.

Medium
1524

Number of Sub-arrays With Odd Sum

Count the number of subarrays with an odd sum using dynamic programming and prefix sum techniques.

Medium
1525

Number of Good Ways to Split a String

Count all valid splits of a string where left and right substrings have equal distinct characters, using efficient state…

Medium
1529

Minimum Suffix Flips

Find the minimum number of operations to convert a binary string to a target string using bit flips.

Medium
1530

Number of Good Leaf Nodes Pairs

Find the number of good leaf node pairs in a binary tree where the shortest path between them is less than or equal to a…

Medium
1535

Find the Winner of an Array Game

Determine the integer that wins an array game by achieving k consecutive victories through simulated pairwise comparison…

Medium
1536

Minimum Swaps to Arrange a Binary Grid

Compute the minimum number of adjacent row swaps to transform a binary grid so all upper-triangle cells are zero using a…

Medium
1540

Can Convert String in K Moves

Determine if string s can be transformed into t within k moves using character shifts and hash table counting efficientl…

Medium
1541

Minimum Insertions to Balance a Parentheses String

Compute the minimum insertions to transform a parentheses string into a balanced string using efficient stack tracking.

Medium
1545

Find Kth Bit in Nth Binary String

Determine the k-th bit in the n-th binary string using a recursive construction that inverts and reverses previous strin…

Medium
1546

Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

Find the maximum number of non-overlapping subarrays that sum to a given target using efficient scanning and hash lookup…

Medium
1551

Minimum Operations to Make Array Equal

Compute the minimum number of operations to equalize a sequential odd-number array using a precise math-driven approach.

Medium
1552

Magnetic Force Between Two Balls

Maximize the minimum magnetic force between balls by strategically placing them in baskets using binary search on positi…

Medium
1557

Minimum Number of Vertices to Reach All Nodes

Identify the minimum set of vertices in a directed acyclic graph from which all nodes are reachable efficiently using gr…

Medium
1558

Minimum Numbers of Function Calls to Make Target Array

Calculate the minimum number of modify calls needed to convert an all-zero array into a given target array using greedy …

Medium
1559

Detect Cycles in 2D Grid

Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.

Medium
1561

Maximum Number of Coins You Can Get

Solve the Maximum Number of Coins You Can Get using greedy pile selection and invariant validation to maximize your coin…

Medium
1562

Find Latest Group of Size M

Determine the latest step where a contiguous group of ones of exact length m exists using array scanning and hash tracki…

Medium
1567

Maximum Length of Subarray With Positive Product

Given an array, find the maximum length of a subarray with a positive product using dynamic programming.

Medium
1573

Number of Ways to Split a String

Count the number of ways to split a binary string into three non-empty parts with equal numbers of '1's.

Medium
1574

Shortest Subarray to be Removed to Make Array Sorted

Find the shortest subarray to remove in order to make an array non-decreasing using binary search and two-pointer techni…

Medium
1577

Number of Ways Where Square of Number Is Equal to Product of Two Numbers

Find the number of triplets where the square of a number equals the product of two others, utilizing array scanning and …

Medium
1578

Minimum Time to Make Rope Colorful

Minimize the time Bob needs to remove balloons to make a rope colorful using dynamic programming with state transitions.

Medium
1583

Count Unhappy Friends

Determine the number of unhappy friends in paired arrangements using array-based simulation for preference violations.

Medium
1584

Min Cost to Connect All Points

Min Cost to Connect All Points asks for the minimum cost to connect all points on a 2D plane, using manhattan distances …

Medium
1589

Maximum Sum Obtained of Any Permutation

Maximize the total sum of requests on nums by greedily assigning larger numbers to most frequently requested indices.

Medium
1590

Make Sum Divisible by P

Determine the minimum-length subarray to remove so the remaining array sum is divisible by a given integer p efficiently…

Medium
1593

Split a String Into the Max Number of Unique Substrings

Maximize unique substrings in a string using backtracking with pruning and hash tables to track substrings.

Medium
1594

Maximum Non Negative Product in a Matrix

Find the maximum non-negative product path in a matrix using dynamic programming and state transition.

Medium
1599

Maximum Profit of Operating a Centennial Wheel

Maximize the profit from operating a Centennial Wheel by determining the optimal number of rotations based on customer a…

Medium
1600

Throne Inheritance

Throne Inheritance requires modeling a dynamic family tree with births and deaths to determine the kingdom's inheritance…

Medium
1604

Alert Using Same Key-Card Three or More Times in a One Hour Period

Solve LeetCode 1604 by grouping swipe times per employee, sorting each list, and scanning for any three within 60 minute…

Medium
1605

Find Valid Matrix Given Row and Column Sums

Given row and column sums, find any valid matrix of non-negative integers that satisfies them.

Medium
1609

Even Odd Tree

Determine if a binary tree meets Even-Odd rules by checking value parity and strict ordering at each level efficiently.

Medium
1615

Maximal Network Rank

Calculate the maximum network rank of two cities by analyzing all city pairs using a graph-driven solution strategy effi…

Medium
1616

Split Two Strings to Make Palindrome

Determine if splitting two equal-length strings at a common index can form a palindrome using two-pointer scanning techn…

Medium
1620

Coordinate With Maximum Network Quality

Determine the coordinate with the maximum network quality by summing signal strengths from all reachable towers efficien…

Medium
1621

Number of Sets of K Non-Overlapping Line Segments

Count all valid arrangements of k non-overlapping line segments on n points using state transition dynamic programming.

Medium
1625

Lexicographically Smallest String After Applying Operations

Optimize a string through rotations and additions to get the lexicographically smallest possible result using string man…

Medium
1626

Best Team With No Conflicts

Find the highest score basketball team by choosing players without conflicts in age and score using dynamic programming.

Medium
1630

Arithmetic Subarrays

Determine whether subarrays of a given array can be rearranged to form arithmetic sequences using array scanning and has…

Medium
1631

Path With Minimum Effort

Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…

Medium
1638

Count Substrings That Differ by One Character

Count all substrings from s that differ by exactly one character from some substring in t using precise substring compar…

Medium
1641

Count Sorted Vowel Strings

Calculate the number of length-n strings with vowels only that are sorted lexicographically using state transitions.

Medium
1642

Furthest Building You Can Reach

Furthest Building You Can Reach explores a greedy approach with heap-based optimization to find the maximum reachable bu…

Medium
1647

Minimum Deletions to Make Character Frequencies Unique

Determine the minimum deletions needed to ensure all character frequencies in a string are unique using a greedy approac…

Medium
1648

Sell Diminishing-Valued Colored Balls

Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.

Medium
1653

Minimum Deletions to Make String Balanced

Determine the minimum number of deletions to transform a string of 'a' and 'b' into a balanced order using DP.

Medium
1654

Minimum Jumps to Reach Home

Find the minimum number of jumps needed to reach a target position while avoiding forbidden positions.

Medium
1657

Determine if Two Strings Are Close

Check if two strings can transform into each other using letter swaps and frequency reorganizations, leveraging hash tab…

Medium
1658

Minimum Operations to Reduce X to Zero

Find the minimum number of operations to reduce a value x to zero by removing elements from an array.

Medium
1663

Smallest String With A Given Numeric Value

Find the lexicographically smallest string of length n with a given numeric value k using a greedy approach.

Medium
1664

Ways to Make a Fair Array

Solve Ways to Make a Fair Array by tracking parity sums before and after each removal with prefix-sum style accounting.

Medium
1669

Merge In Between Linked Lists

Merge a second linked list into a first by removing a specified range of nodes, testing precise pointer updates and list…

Medium
1670

Design Front Middle Back Queue

Implement a queue that efficiently handles push and pop operations at the front, middle, and back using pointer manipula…

Medium
1673

Find the Most Competitive Subsequence

Identify the lexicographically smallest subsequence of size k using stack-based greedy selection in array traversal.

Medium
1674

Minimum Moves to Make Array Complementary

Find the minimum moves to make an array complementary by analyzing paired sums and using hash lookups for efficiency.

Medium
1679

Max Number of K-Sum Pairs

Max Number of K-Sum Pairs is a problem involving counting disjoint pairs with a given sum k in an array.

Medium
1680

Concatenation of Consecutive Binary Numbers

Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.

Medium
1685

Sum of Absolute Differences in a Sorted Array

Calculate the sum of absolute differences between each element and others in a sorted array efficiently.

Medium
1686

Stone Game VI

Determine the winner in Stone Game VI using a greedy strategy that accounts for each stone's dual value impact on Alice …

Medium
1689

Partitioning Into Minimum Number Of Deci-Binary Numbers

This problem asks to find the minimum number of deci-binary numbers needed to sum to a given number represented as a str…

Medium
1690

Stone Game VII

Maximize score difference in a two-player turn-based stone removal game using state transition dynamic programming.

Medium
1695

Maximum Erasure Value

Maximize the score by erasing a subarray with unique elements in an array of integers.

Medium
1696

Jump Game VI

Jump Game VI challenges you to maximize your score while jumping through an array using state transition dynamic program…

Medium
1701

Average Waiting Time

Compute the average waiting time for customers using array traversal and simulation of a single chef processing orders s…

Medium
1702

Maximum Binary String After Change

The problem asks to maximize a binary string using specific operations to get the highest possible value.

Medium
1705

Maximum Number of Eaten Apples

Maximize apples eaten by choosing the best apples first, considering their rot days and available days to eat them.

Medium
1706

Where Will the Ball Fall

Determine where each ball exits a diagonal board grid or if it gets stuck, using matrix simulation with careful traversa…

Medium
1711

Count Good Meals

Count Good Meals asks you to find pairs of food items with a sum of deliciousness equal to a power of two.

Medium
1712

Ways to Split Array Into Three Subarrays

The problem requires finding the number of ways to split an array into three subarrays where each split meets a certain …

Medium
1717

Maximum Score From Removing Substrings

Compute the highest score by greedily removing specific substrings using a stack to track state transitions efficiently.

Medium
1718

Construct the Lexicographically Largest Valid Sequence

Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…

Medium
1721

Swapping Nodes in a Linked List

Swap nodes in a linked list using linked-list pointer manipulation and two pointers to solve this medium difficulty prob…

Medium
1722

Minimize Hamming Distance After Swap Operations

Solve Minimize Hamming Distance After Swap Operations by grouping swappable indices and matching value counts inside eac…

Medium
1726

Tuple with Same Product

Given an array of distinct integers, return the number of tuples where the product of two pairs is the same.

Medium
1727

Largest Submatrix With Rearrangements

Rearrange columns of a binary matrix to find the largest submatrix of 1s.

Medium
1733

Minimum Number of People to Teach

Minimize the number of users to teach a language that ensures all friends can communicate in a social network.

Medium
1734

Decode XORed Permutation

Decode XORed Permutation uses prefix reconstruction with global XOR to recover the hidden odd-length permutation in line…

Medium
1737

Change Minimum Characters to Satisfy One of Three Conditions

This problem asks for the minimum operations to change two strings so that one of three conditions is met.

Medium
1738

Find Kth Largest XOR Coordinate Value

Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…

Medium
1743

Restore the Array From Adjacent Pairs

Restore the Array From Adjacent Pairs reconstructs a sequence using adjacent element pairs. Efficient hash lookups and a…

Medium
1744

Can You Eat Your Favorite Candy on Your Favorite Day?

Determine if you can eat a candy of your favorite type on a specific day, given daily limits and candy availability.

Medium
1749

Maximum Absolute Sum of Any Subarray

Solve for the maximum absolute sum of any subarray using dynamic programming and understanding state transitions.

Medium
1750

Minimum Length of String After Deleting Similar Ends

Minimize string length by deleting similar characters from both ends repeatedly using a two-pointer technique.

Medium
1753

Maximum Score From Removing Stones

Maximize the score in a solitaire game by optimally removing stones from three piles with a greedy approach.

Medium
1754

Largest Merge Of Two Strings

Construct the lexicographically largest merge from two strings using a two-pointer greedy scanning approach efficiently.

Medium
1759

Count Number of Homogenous Substrings

This problem requires counting all homogenous substrings in a given string and returning the result modulo 10^9 + 7.

Medium
1760

Minimum Limit of Balls in a Bag

Find the minimum penalty (maximum balls in a bag) after performing up to maxOperations to split bags of balls.

Medium
1764

Form Array by Concatenating Subarrays of Another Array

Determine if you can sequentially select disjoint subarrays from nums matching each group in order using two-pointer sca…

Medium
1765

Map of Highest Peak

Solve the Map of Highest Peak problem using breadth-first search to assign heights based on proximity to water cells.

Medium
1769

Minimum Number of Operations to Move All Balls to Each Box

Solve the problem of finding the minimum operations to move balls to each box using an efficient approach with arrays an…

Medium
1774

Closest Dessert Cost

Find the closest dessert cost to a target by selecting from a list of base flavors and topping combinations using dynami…

Medium
1775

Equal Sum Arrays With Minimum Number of Operations

Solve the problem of balancing the sums of two integer arrays with minimal operations, using array scanning and hash loo…

Medium
1780

Check if Number is a Sum of Powers of Three

Determine if a number can be expressed as the sum of distinct powers of three using a math-driven strategy.

Medium
1781

Sum of Beauty of All Substrings

Calculate the total beauty of all substrings by counting character frequencies and computing frequency differences effic…

Medium
1785

Minimum Elements to Add to Form a Given Sum

Compute the gap between current sum and goal, then greedily cover it with limit-sized additions to get the minimum count…

Medium
1786

Number of Restricted Paths From First to Last Node

Solve the problem of finding the number of restricted paths in a weighted undirected graph, leveraging graph algorithms …

Medium
1792

Maximum Average Pass Ratio

Maximize the average pass ratio by assigning extra guaranteed-passing students using a greedy heap strategy for optimal …

Medium
1797

Design Authentication Manager

Implement an AuthenticationManager using linked-list pointer manipulation and a hash map to track token expirations effi…

Medium
1798

Maximum Number of Consecutive Values You Can Make

Find the maximum number of consecutive integer values starting from zero that can be formed using your coins array.

Medium
1801

Number of Orders in the Backlog

Determine the total number of unfulfilled buy and sell orders using heaps to simulate backlog processing efficiently in …

Medium
1802

Maximum Value at a Given Index in a Bounded Array

Maximize the value at a given index of an array with constraints using binary search over the valid answer space.

Medium
1806

Minimum Number of Operations to Reinitialize a Permutation

Find the minimum number of operations to reinitialize a permutation of size n using specific operations.

Medium
1807

Evaluate the Bracket Pairs of a String

Quickly evaluate a string with bracketed keys using array scanning and hash table lookups for efficient replacements.

Medium
1813

Sentence Similarity III

Sentence Similarity III asks if one sentence can be transformed into another by inserting a sentence inside it.

Medium
1814

Count Nice Pairs in an Array

Count Nice Pairs in an Array requires efficiently pairing numbers where nums[i] + rev(nums[j]) equals nums[j] + rev(nums…

Medium
1817

Finding the Users Active Minutes

This problem requires counting unique minutes of user activity on LeetCode based on a series of logs and an integer k.

Medium
1818

Minimum Absolute Sum Difference

Minimize the absolute sum difference between two integer arrays by replacing at most one element from the first array.

Medium
1823

Find the Winner of the Circular Game

Find the winner of a circular game by simulating the elimination process with a queue-driven approach.

Medium
1824

Minimum Sideway Jumps

Solve the Minimum Sideway Jumps problem using state transition dynamic programming to minimize side jumps while navigati…

Medium
1828

Queries on Number of Points Inside a Circle

Determine how many 2D points lie within multiple circles using array iteration and Euclidean distance calculations effic…

Medium
1829

Maximum XOR for Each Query

Find the maximum XOR for each query based on a sorted array and bit manipulation.

Medium
1833

Maximum Ice Cream Bars

Maximize the number of ice cream bars a boy can buy by applying a greedy choice strategy based on cost sorting.

Medium
1834

Single-Threaded CPU

Simulate task processing with a single-threaded CPU by sorting and prioritizing tasks based on arrival and processing ti…

Medium
1838

Frequency of the Most Frequent Element

Maximize the frequency of an element in an array by incrementing at most `k` elements. Use binary search and greedy tech…

Medium
1839

Longest Substring Of All Vowels in Order

Find the longest substring of all vowels in order within a given string of vowels using sliding window technique.

Medium
1845

Seat Reservation Manager

Manage seat reservations efficiently using a design combining priority queue to always return the lowest available seat …

Medium
1846

Maximum Element After Decreasing and Rearranging

Determine the maximum value in an array after decreasing elements and rearranging using a greedy invariant approach.

Medium
1849

Splitting a String Into Descending Consecutive Values

Check if a string of digits can be split into descending consecutive values where the difference between them is 1.

Medium
1850

Minimum Adjacent Swaps to Reach the Kth Smallest Number

Find the minimum number of adjacent swaps to reach the kth smallest wonderful integer from a given number string.

Medium
1855

Maximum Distance Between a Pair of Values

Find the maximum distance between a pair of values in two non-increasing integer arrays using binary search.

Medium
1856

Maximum Subarray Min-Product

The problem asks to find the maximum min-product of any non-empty subarray of nums.

Medium
1860

Incremental Memory Leak

Solve Incremental Memory Leak by simulating each second carefully and using math to reason about the crash time bound.

Medium
1861

Rotating the Box

Rotate a box represented by a character matrix, letting stones fall under gravity using precise two-pointer scanning and…

Medium
1864

Minimum Number of Swaps to Make the Binary String Alternating

This problem requires finding the minimum number of swaps to make a binary string alternating or determine if it's impos…

Medium
1865

Finding Pairs With a Certain Sum

Efficiently track and count pairs across two arrays using array scanning plus hash lookup to support dynamic updates.

Medium
1870

Minimum Speed to Arrive on Time

This problem asks to find the minimum speed of trains to reach on time using binary search.

Medium
1871

Jump Game VII

The problem asks to determine if we can reach the last index of a binary string, with a set range of jumps between indic…

Medium
1877

Minimize Maximum Pair Sum in Array

Minimize the maximum pair sum in an array by optimally pairing its elements.

Medium
1878

Get Biggest Three Rhombus Sums in a Grid

Find the three largest distinct rhombus sums from a given grid using array and math techniques.

Medium
1881

Maximum Value after Insertion

Solve Maximum Value after Insertion by greedily placing x at the first digit that makes the resulting signed number larg…

Medium
1882

Process Tasks Using Servers

Assign tasks to servers efficiently using arrays and heaps, resolving ties by weight and index while tracking availabili…

Medium
1884

Egg Drop With 2 Eggs and N Floors

Determine the minimum drops needed to find the critical floor using 2 eggs with optimized state transition dynamic progr…

Medium
1887

Reduction Operations to Make the Array Elements Equal

Find the minimum number of operations to make all array elements equal by reducing the largest elements to the next smal…

Medium
1888

Minimum Number of Flips to Make the Binary String Alternating

Find the minimum number of flips to make a binary string alternate, using state transition dynamic programming.

Medium
1894

Find the Student that Will Replace the Chalk

Identify the first student who will run out of chalk using a simulation with prefix sums and binary search.

Medium
1895

Largest Magic Square

Find the side length of the largest magic square in a matrix where row, column, and diagonal sums are equal.

Medium
1898

Maximum Number of Removable Characters

Use binary search and a subsequence check to find the largest removable prefix that still keeps p inside s.

Medium
1899

Merge Triplets to Form Target Triplet

Determine if target triplet can be formed by merging given triplets using greedy selection and invariant checks.

Medium
1901

Find a Peak Element II

Locate any peak in a 2D matrix using binary search across rows or columns for efficient discovery and verification.

Medium
1904

The Number of Full Rounds You Have Played

Solve this math plus string problem to calculate the number of full rounds played in a chess tournament between login an…

Medium
1905

Count Sub Islands

Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…

Medium
1906

Minimum Absolute Difference Queries

Compute minimum absolute differences for subarrays efficiently using array scanning and hash table lookups, leveraging b…

Medium
1910

Remove All Occurrences of a Substring

Remove all occurrences of a specified substring from a string using efficient stack-based state management.

Medium
1911

Maximum Alternating Subsequence Sum

Maximize alternating subsequence sum with dynamic programming and state transitions in an array.

Medium
1914

Cyclically Rotating a Grid

This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …

Medium
1915

Number of Wonderful Substrings

Count the number of wonderful non-empty substrings of a given string based on frequency conditions of characters.

Medium
1921

Eliminate Maximum Number of Monsters

Eliminate monsters by strategically using a weapon in a video game to stop them before they reach your city.

Medium
1922

Count Good Numbers

Count Good Numbers uses a mathematical pattern with recursion to efficiently count digit strings of length n under stric…

Medium
1926

Nearest Exit from Entrance in Maze

Find the shortest path from the maze entrance to the nearest border exit using BFS over a 2D array matrix efficiently.

Medium
1927

Sum Game

Determine if Alice can force a win in the Sum Game by strategically replacing '?' using a greedy and invariant approach.

Medium
1930

Unique Length-3 Palindromic Subsequences

Count all unique length-3 palindromic subsequences in a string efficiently using hash tables and character positions.

Medium
1936

Add Minimum Number of Rungs

Determine the fewest rungs to add to climb a strictly increasing ladder using a greedy step-by-step approach.

Medium
1937

Maximum Number of Points with Cost

Maximize your points in a matrix by selecting cells row by row while accounting for distance penalties using dynamic pro…

Medium
1942

The Number of the Smallest Unoccupied Chair

Solve The Number of the Smallest Unoccupied Chair by sorting arrivals and managing freed seats before each new assignmen…

Medium
1943

Describe the Painting

Solve the problem of describing a painted segment with mixed colors using array scanning and hash table lookups.

Medium
1946

Largest Number After Mutating Substring

Find the largest integer by mutating a substring of a number using a mapping array for each digit.

Medium
1947

Maximum Compatibility Score Sum

Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…

Medium
1953

Maximum Number of Weeks for Which You Can Work

Maximize the number of weeks you can work on projects with milestone constraints using a greedy approach and invariant v…

Medium
1954

Minimum Garden Perimeter to Collect Enough Apples

Find the minimum perimeter of a square garden that holds enough apples based on a specific formula involving binary sear…

Medium
1958

Check if Move is Legal

Determine if a move on an 8x8 board is legal by validating lines in all directions using array and matrix patterns.

Medium
1959

Minimum Total Space Wasted With K Resizing Operations

Find the minimum total space wasted in a dynamic array with at most k resizing operations.

Medium
1962

Remove Stones to Minimize the Total

Minimize the total stones by repeatedly removing half from the largest pile using a greedy heap strategy.

Medium
1963

Minimum Number of Swaps to Make the String Balanced

Determine the minimum swaps to balance a bracket string using two-pointer scanning with invariant tracking efficiently.

Medium
1968

Array With Elements Not Equal to Average of Neighbors

Rearrange an array such that no element equals the average of its neighbors using a greedy approach.

Medium
1969

Minimum Non-Zero Product of the Array Elements

The problem asks to minimize the product of an array after performing bit-swapping operations on its binary representati…

Medium
1975

Maximum Matrix Sum

Maximize the sum of an n x n integer matrix using row and column negation operations efficiently with a greedy approach.

Medium
1976

Number of Ways to Arrive at Destination

Find the number of ways to travel from intersection 0 to n - 1 in the shortest time, using a graph-based approach.

Medium
1980

Find Unique Binary String

Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.

Medium
1981

Minimize the Difference Between Target and Chosen Elements

This problem asks to select one element per row to minimize the absolute difference from a target sum using dynamic prog…

Medium
1985

Find the Kth Largest Integer in the Array

This problem asks to find the kth largest integer in an array of string numbers, highlighting sorting and string-based c…

Medium
1986

Minimum Number of Work Sessions to Finish the Tasks

Find the minimum number of work sessions needed to finish a set of tasks, considering task durations and session time.

Medium
1992

Find All Groups of Farmland

Identify all rectangular farmland groups in a binary matrix using array traversal and depth-first search efficiently.

Medium
1993

Operations on Tree

Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.

Medium
1996

The Number of Weak Characters in the Game

Identify all weak characters in a game by analyzing attack and defense values using a stack-based greedy sorting approac…

Medium
1997

First Day Where You Have Been in All the Rooms

Calculate the first day you have visited all rooms using state transition dynamic programming on the nextVisit array.

Medium
2001

Number of Pairs of Interchangeable Rectangles

Count all pairs of rectangles that share the exact width-to-height ratio using efficient array scanning and hash lookup.

Medium
2002

Maximum Product of the Length of Two Palindromic Subsequences

Find two disjoint palindromic subsequences in a string to maximize the product of their lengths efficiently using dynami…

Medium
2007

Find Original Array From Doubled Array

Given a shuffled array, determine if it is a doubled array and find the original array.

Medium
2008

Maximum Earnings From Taxi

Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.

Medium
2012

Sum of Beauty in the Array

Calculate the sum of beauty for array elements using prefix and suffix tracking to optimize evaluation across indices ef…

Medium
2013

Detect Squares

Detect Squares requires tracking points on a 2D plane to quickly count all possible axis-aligned squares using efficient…

Medium
2017

Grid Game

Solve the Grid Game problem by optimizing the movement of two robots on a 2D matrix grid.

Medium
2018

Check if Word Can Be Placed In Crossword

Determine if a word fits in a crossword grid using array and matrix checks, accounting for spaces, letters, and blocked …

Medium
2023

Number of Pairs of Strings With Concatenation Equal to Target

Count all unique index pairs in a string array whose concatenation exactly matches the given target string using efficie…

Medium
2024

Maximize the Confusion of an Exam

Maximize the Confusion of an Exam requires adjusting at most k answers to create the longest consecutive true or false s…

Medium
2028

Find Missing Observations

Given a set of dice rolls, calculate the missing observations based on the mean and return them or determine if it's imp…

Medium
2029

Stone Game IX

In the Stone Game IX problem, Alice and Bob take turns removing stones, and Alice wins if the sum of removed stones is d…

Medium
2033

Minimum Operations to Make a Uni-Value Grid

Determine the fewest additions or subtractions of x to make all grid elements identical using array and math logic.

Medium
2034

Stock Price Fluctuation

Design an efficient algorithm for managing stock price fluctuations with incorrect and unordered data in a data stream.

Medium
2038

Remove Colored Pieces if Both Neighbors are the Same Color

Alice and Bob play a game removing colored pieces; Alice wins if she makes the last valid move.

Medium
2039

The Time When the Network Becomes Idle

Calculate the time when the network becomes idle, factoring in message resending and the BFS traversal method.

Medium
2043

Simple Bank System

Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…

Medium
2044

Count Number of Maximum Bitwise-OR Subsets

Determine the number of non-empty subsets that achieve the maximum bitwise OR using efficient backtracking and pruning s…

Medium
2048

Next Greater Numerically Balanced Number

Find the smallest numerically balanced number greater than a given integer using backtracking search and pruning.

Medium
2049

Count Nodes With the Highest Score

Find the number of nodes with the highest score in a binary tree, based on subtree sizes and node removal.

Medium
2054

Two Best Non-Overlapping Events

Maximize the total value of at most two non-overlapping events using state transition dynamic programming efficiently.

Medium
2055

Plates Between Candles

Determine the number of plates between candles in a given substring using binary search and prefix sum techniques.

Medium
2058

Find the Minimum and Maximum Number of Nodes Between Critical Points

Find the minimum and maximum number of nodes between critical points in a linked list by identifying local minima and ma…

Medium
2059

Minimum Operations to Convert Number

Determine the minimum operations needed to convert a number using array elements with addition, subtraction, or XOR oper…

Medium
2063

Vowels of All Substrings

Compute the total number of vowels in all substrings of a given string using efficient state transition dynamic programm…

Medium
2064

Minimized Maximum of Products Distributed to Any Store

Distribute products to stores so the largest store allocation is minimized using binary search over possible maximums.

Medium
2069

Walking Robot Simulation II

The Walking Robot Simulation II problem challenges you to simulate robot movements and track its position and direction …

Medium
2070

Most Beautiful Item for Each Query

Determine the maximum beauty of items affordable for each query using efficient binary search and sorting techniques.

Medium
2074

Reverse Nodes in Even Length Groups

Reverse nodes in even length groups while keeping the odd-length groups intact in a given linked list.

Medium
2075

Decode the Slanted Ciphertext

Decode the Slanted Ciphertext problem requires decoding a slanted cipher using string manipulation and simulation based …

Medium
2079

Watering Plants

Simulate watering plants while managing a watering can's capacity, considering distance and refills.

Medium
2080

Range Frequency Queries

Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…

Medium
2086

Minimum Number of Food Buckets to Feed the Hamsters

Find the minimum number of food buckets required to feed all hamsters, using dynamic programming and greedy techniques.

Medium
2087

Minimum Cost Homecoming of a Robot in a Grid

Find the minimum cost for a robot to return home in a grid with row and column movement costs.

Medium
2090

K Radius Subarray Averages

Efficiently calculate the k-radius average for subarrays using sliding window technique.

Medium
2091

Removing Minimum and Maximum From Array

The problem asks to remove the minimum and maximum elements from an array with the fewest deletions.

Medium
2095

Delete the Middle Node of a Linked List

Efficiently remove the middle node from a linked list using two-pointer techniques and careful pointer updates to mainta…

Medium
2096

Step-By-Step Directions From a Binary Tree Node to Another

Find the shortest path between two nodes in a binary tree and output the directions as a string of 'L', 'R', and 'U'.

Medium
2100

Find Good Days to Rob the Bank

Find good days to rob the bank by identifying days with non-increasing and non-decreasing guard counts using dynamic pro…

Medium
2101

Detonate the Maximum Bombs

Determine the maximum number of bombs that can be detonated by leveraging chain reactions using graph traversal and DFS …

Medium
2104

Sum of Subarray Ranges

Compute the total sum of ranges for all contiguous subarrays efficiently using stack-based state management techniques.

Medium
2105

Watering Plants II

Simulate watering a row of plants with Alice and Bob using two-pointer scanning, tracking refills precisely for each ste…

Medium
2109

Adding Spaces to a String

Learn to efficiently insert spaces in a string using two-pointer scanning with invariant tracking in linear time.

Medium
2110

Number of Smooth Descent Periods of a Stock

Count all contiguous periods where stock prices descend smoothly by exactly one using dynamic programming techniques.

Medium
2115

Find All Possible Recipes from Given Supplies

Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …

Medium
2116

Check if a Parentheses String Can Be Valid

Determine if a parentheses string can be transformed into a valid sequence considering locked positions using stack logi…

Medium
2120

Execution of All Suffix Instructions Staying in a Grid

Simulate robot moves from every instruction index on an n x n grid, counting valid steps without leaving boundaries.

Medium
2121

Intervals Between Identical Elements

Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.

Medium
2125

Number of Laser Beams in a Bank

Calculate total laser beams in a bank floor plan using array counting and math logic between security devices on differe…

Medium
2126

Destroying Asteroids

This problem requires destroying asteroids by choosing the right order of collisions based on mass, using a greedy appro…

Medium
2130

Maximum Twin Sum of a Linked List

Find the maximum twin sum in a linked list by manipulating pointers efficiently and leveraging stack or reversal techniq…

Medium
2131

Longest Palindrome by Concatenating Two Letter Words

Find the maximum-length palindrome by combining two-letter words using array scanning and hash table lookups efficiently…

Medium
2134

Minimum Swaps to Group All 1's Together II

Solve the minimum swaps to group all 1's together in a circular binary array using an optimized sliding window approach.

Medium
2135

Count Words Obtained After Adding a Letter

Given startWords and targetWords, check how many targetWords can be formed by adding one letter and rearranging letters …

Medium
2139

Minimum Moves to Reach Target Score

Calculate the fewest steps to reach a target integer using increments and limited doubles with a greedy strategy.

Medium
2140

Solving Questions With Brainpower

Maximize points in an exam with state transition dynamic programming by deciding whether to solve or skip each question.

Medium
2145

Count the Hidden Sequences

Given a sequence of differences, count how many hidden sequences fit within a range using an array and prefix sum approa…

Medium
2146

K Highest Ranked Items Within a Price Range

Use BFS to rank reachable shop items by distance, price, row, and column, then return the best k coordinates.

Medium
2149

Rearrange Array Elements by Sign

Rearrange an array by alternating positive and negative integers using a two-pointer approach with invariant tracking.

Medium
2150

Find All Lonely Numbers in the Array

Find lonely numbers in an array where each lonely number appears once and has no adjacent values.

Medium
2155

All Divisions With the Highest Score of a Binary Array

Find all indices in a binary array where division score is maximized.

Medium
2161

Partition Array According to Given Pivot

Rearrange an array around a pivot while maintaining relative order using a two-pointer scanning approach efficiently.

Medium
2162

Minimum Cost to Set Cooking Time

Calculate the minimum fatigue to set a microwave cooking time using digit moves and pushes efficiently.

Medium
2165

Smallest Value of the Rearranged Number

Rearrange the digits of an integer to minimize its value while avoiding leading zeros, keeping the sign unchanged.

Medium
2166

Design Bitset

Master the Design Bitset problem by efficiently managing bit flips, counts, and indexed updates with array and hash look…

Medium
2170

Minimum Operations to Make the Array Alternating

Given an array, calculate the minimum number of operations needed to make it alternating.

Medium
2171

Removing Minimum Number of Magic Beans

Determine the minimum beans to remove so all remaining non-empty bags have equal beans using a greedy approach.

Medium
2177

Find Three Consecutive Integers That Sum to a Given Number

Given a number, find three consecutive integers that sum to it, or return an empty array if no such integers exist.

Medium
2178

Maximum Split of Positive Even Integers

Determine the largest set of unique positive even integers that sum to a given finalSum using backtracking and greedy se…

Medium
2181

Merge Nodes in Between Zeros

This problem requires merging nodes between zeros in a linked list by summing up the values between consecutive zeros.

Medium
2182

Construct String With Repeat Limit

Construct a lexicographically largest string from a given string with no letter appearing more than a repeatLimit times …

Medium
2186

Minimum Number of Steps to Make Two Strings Anagram II

Compute the fewest character insertions needed to turn two strings into anagrams using hash table frequency counts effic…

Medium
2187

Minimum Time to Complete Trips

Find the minimum time required for buses to complete at least totalTrips using binary search over time multiples.

Medium
2191

Sort the Jumbled Numbers

Sort numbers based on a custom mapping of their digits, leveraging array manipulation and sorting techniques.

Medium
2192

All Ancestors of a Node in a Directed Acyclic Graph

Solve the All Ancestors of a Node in a Directed Acyclic Graph problem using graph traversal techniques like BFS, DFS, an…

Medium
2195

Append K Integers With Minimal Sum

In this problem, you need to append k unique positive integers to a given array nums such that the sum is minimized.

Medium
2196

Create Binary Tree From Descriptions

Build a binary tree from descriptions of parent-child relationships using array scanning and hash lookup.

Medium
2201

Count Artifacts That Can Be Extracted

Count the number of artifacts that can be extracted after excavating specified grid cells.

Medium
2202

Maximize the Topmost Element After K Moves

Maximize the topmost element in a pile after making exactly k moves using a greedy strategy and invariant checks.

Medium
2207

Maximize Number of Subsequences in a String

Maximize the number of subsequences by optimally adding a character to a given string to match a specified pattern.

Medium
2208

Minimum Operations to Halve Array Sum

Minimize operations to halve an array's sum using greedy choices and heap data structures.

Medium
2211

Count Collisions on a Road

Count Collisions on a Road is a problem where you calculate the number of car collisions based on their movements in a s…

Medium
2212

Maximum Points in an Archery Competition

In the "Maximum Points in an Archery Competition" problem, Bob aims to maximize his score while respecting Alice's arrow…

Medium
2216

Minimum Deletions to Make Array Beautiful

Determine the minimum deletions required to transform an array into a beautiful sequence using stack-based state managem…

Medium
2217

Find Palindrome With Fixed Length

Find the smallest palindromes of a given length for specific queries with mathematical and array manipulation.

Medium
2221

Find Triangular Sum of an Array

The problem asks for calculating the triangular sum of an array through repeated pairwise summation.

Medium
2222

Number of Ways to Select Buildings

Solve Number of Ways to Select Buildings by counting alternating 3-building patterns with state transitions over the bin…

Medium
2225

Find Players With Zero or One Losses

Identify players with zero or one losses by efficiently scanning arrays and counting losses using hash lookups for accur…

Medium
2226

Maximum Candies Allocated to K Children

Maximize candies allocation for k children by dividing piles into sub-piles using binary search.

Medium
2232

Minimize Result by Adding Parentheses to Expression

Enumerate every valid parenthesis placement around the plus sign and choose the expression with the smallest evaluated p…

Medium
2233

Maximum Product After K Increments

Maximize the product of an array after performing up to k increments using a greedy approach with heap optimization.

Medium
2240

Number of Ways to Buy Pens and Pencils

Calculate all distinct ways to spend a fixed total on pens and pencils using a straightforward enumeration strategy.

Medium
2241

Design an ATM Machine

Design an ATM machine that stores and withdraws money with given denominations and prioritizes larger values during with…

Medium
2244

Minimum Rounds to Complete All Tasks

The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.

Medium
2245

Maximum Trailing Zeros in a Cornered Path

Find the maximum trailing zeros in the product of a cornered path within a 2D grid.

Medium
2249

Count Lattice Points Inside a Circle

Count the number of lattice points inside at least one circle in a grid, based on given center and radius data.

Medium
2250

Count Number of Rectangles Containing Each Point

Given a set of rectangles and points, determine how many rectangles contain each point.

Medium
2256

Minimum Average Difference

Find the index with the minimum average difference in an array using prefix sums.

Medium
2257

Count Unguarded Cells in the Grid

Solve Count Unguarded Cells in the Grid by marking guard sight lines across a blocked matrix and counting untouched empt…

Medium
2260

Minimum Consecutive Cards to Pick Up

Solve Minimum Consecutive Cards to Pick Up by tracking each card's last index and minimizing duplicate spans during one …

Medium
2261

K Divisible Elements Subarrays

Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…

Medium
2265

Count Nodes Equal to Average of Subtree

Given a binary tree, count nodes where the value equals the average of values in its subtree.

Medium
2266

Count Number of Texts

Calculate the total number of possible original texts from a pressed key sequence using state transition dynamic program…

Medium
2270

Number of Ways to Split Array

Count all valid ways to split a 0-indexed integer array into two non-empty parts using array plus prefix sum logic effic…

Medium
2271

Maximum White Tiles Covered by a Carpet

Solve Maximum White Tiles Covered by a Carpet by sorting intervals, checking optimal carpet starts, and counting full pl…

Medium
2274

Maximum Consecutive Floors Without Special Floors

Find the maximum sequence of consecutive floors without any special floors using array sorting techniques efficiently.

Medium
2275

Largest Combination With Bitwise AND Greater Than Zero

Find the largest group of integers in an array whose bitwise AND is greater than zero using array scanning and hash look…

Medium
2279

Maximum Bags With Full Capacity of Rocks

Maximize the number of bags filled to capacity by distributing additional rocks using a greedy approach.

Medium
2280

Minimum Lines to Represent a Line Chart

Determine the fewest lines needed to accurately connect stock price points in a line chart using array and math reasonin…

Medium
2284

Sender With Largest Word Count

Find the sender with the largest total word count by scanning messages and tallying counts using a hash table efficientl…

Medium
2285

Maximum Total Importance of Roads

Assign unique values to cities to maximize the total importance of all roads using greedy selection based on city connec…

Medium
2288

Apply Discount to Prices

Apply Discount to Prices involves updating a sentence by applying a percentage discount to price words, with precise for…

Medium
2289

Steps to Make Array Non-decreasing

Determine the minimum steps to make an array non-decreasing using linked-list pointer manipulation and monotonic stack t…

Medium
2294

Partition Array Such That Maximum Difference Is K

Find the minimum number of subsequences required such that the difference between the maximum and minimum value in each …

Medium
2295

Replace Elements in an Array

Replace Elements in an Array involves applying a series of operations to replace values in an array with new ones based …

Medium
2300

Successful Pairs of Spells and Potions

Count how many potions pair successfully with each spell using binary search over sorted potion strengths efficiently.

Medium
2304

Minimum Path Cost in a Grid

Minimize the cost of a path in a grid while considering move costs for each step.

Medium
2305

Fair Distribution of Cookies

The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…

Medium
2310

Sum of Numbers With Units Digit K

Determine the minimum set of positive integers whose units digits match k and sum exactly to num using DP patterns.

Medium
2311

Longest Binary Subsequence Less Than or Equal to K

Find the longest subsequence in a binary string that forms a number less than or equal to a given integer k.

Medium
2316

Count Unreachable Pairs of Nodes in an Undirected Graph

Calculate the total number of node pairs in an undirected graph that cannot reach each other using DFS, BFS, or Union Fi…

Medium
2317

Maximum XOR After Operations

Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.

Medium
2320

Count Number of Ways to Place Houses

This problem asks you to calculate the number of ways to place houses along a street while preventing adjacent houses on…

Medium
2326

Spiral Matrix IV

In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.

Medium
2327

Number of People Aware of a Secret

Calculate how many people know a secret over n days using state transition dynamic programming and careful simulation of…

Medium
2332

The Latest Time to Catch a Bus

Find the latest time to catch a bus based on departure times, passenger arrivals, and capacity using binary search over …

Medium
2333

Minimum Sum of Squared Difference

Calculate the minimum sum of squared differences between two arrays using limited modifications and binary search techni…

Medium
2336

Smallest Number in Infinite Set

Design a data structure to handle the smallest missing element in an infinite set, with the ability to add and remove el…

Medium
2337

Move Pieces to Obtain a String

Determine if the pieces in start can be moved to form target using two-pointer scanning and strict left-right movement r…

Medium
2342

Max Sum of a Pair With Equal Sum of Digits

Find the maximum sum of two numbers with equal digit sums in a given array of positive integers.

Medium
2343

Query Kth Smallest Trimmed Number

Solve the Query Kth Smallest Trimmed Number problem by efficiently trimming and sorting strings in an array to answer qu…

Medium
2348

Number of Zero-Filled Subarrays

Given an array of integers, count the subarrays that consist entirely of 0s.

Medium
2349

Design a Number Container System

Learn to implement a Number Container System using hash tables and design techniques to efficiently track numbers and in…

Medium
2352

Equal Row and Column Pairs

Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…

Medium
2353

Design a Food Rating System

Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.

Medium
2358

Maximum Number of Groups Entering a Competition

Determine the maximum number of ordered non-empty student groups for a competition using grades array analysis and binar…

Medium
2359

Find Closest Node to Given Two Nodes

Find the node that minimizes the maximum distance to two given nodes in a directed graph with one outgoing edge per node…

Medium
2364

Count Number of Bad Pairs

Count the number of bad pairs in an array where the difference between indices and values does not match.

Medium
2365

Task Scheduler II

Complete tasks in the optimal number of days by considering breaks and task type constraints.

Medium
2368

Reachable Nodes With Restrictions

In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…

Medium
2369

Check if There is a Valid Partition For The Array

This problem challenges you to determine if an array can be partitioned into valid subarrays using dynamic programming.

Medium
2370

Longest Ideal Subsequence

The Longest Ideal Subsequence problem involves finding the longest subsequence where each character has a difference of …

Medium
2374

Node With Highest Edge Score

Determine the node with the highest edge score in a graph using hash table aggregation and careful index tracking.

Medium
2375

Construct Smallest Number From DI String

Construct the lexicographically smallest string that fits the increasing and decreasing conditions of a given pattern.

Medium
2380

Time Needed to Rearrange a Binary String

Calculate the exact seconds required to convert all 01 pairs into 10 in a binary string using state transitions.

Medium
2381

Shifting Letters II

Shift letters in a string using a sequence of range-based forward or backward operations efficiently with prefix sums.

Medium
2384

Largest Palindromic Number

Form the largest palindromic number from a string of digits while maintaining a valid palindrome structure.

Medium
2385

Amount of Time for Binary Tree to Be Infected

The problem asks to calculate the number of minutes for an infection to spread across all nodes in a binary tree startin…

Medium
2390

Removing Stars From a String

Remove all stars from a string by simulating the removal process using a stack to manage characters and stars efficientl…

Medium
2391

Minimum Amount of Time to Collect Garbage

This problem asks you to find the minimum amount of time needed to collect all garbage in a city, focusing on array and …

Medium
2396

Strictly Palindromic Number

Determine if a number is strictly palindromic in all bases from 2 to n minus 2 using two-pointer scanning and invariant …

Medium
2397

Maximum Rows Covered by Columns

Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…

Medium
2400

Number of Ways to Reach a Position After Exactly k Steps

Find the number of ways to reach a position after exactly k steps on an infinite number line using dynamic programming.

Medium
2401

Longest Nice Subarray

Find the length of the longest nice subarray where the bitwise AND of all pairs of elements in the subarray is zero.

Medium
2405

Optimal Partition of String

Given a string s, partition it into substrings with unique characters and return the minimum number of substrings.

Medium
2406

Divide Intervals Into Minimum Number of Groups

Determine the minimum number of non-overlapping groups for a set of intervals using precise two-pointer scanning logic.

Medium
2410

Maximum Matching of Players With Trainers

Maximize the number of valid player-trainer matchings using two-pointer scanning and careful sorting strategy.

Medium
2411

Smallest Subarrays With Maximum Bitwise OR

Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.

Medium
2414

Length of the Longest Alphabetical Continuous Substring

Find the length of the longest continuous alphabetical substring from a given string of lowercase letters.

Medium
2415

Reverse Odd Levels of Binary Tree

Reverse the node values at each odd level in a perfect binary tree, preserving the even levels.

Medium
2419

Longest Subarray With Maximum Bitwise AND

Find the length of the longest subarray whose bitwise AND reaches the array's maximum value, combining array scanning wi…

Medium
2420

Find All Good Indices

Identify all indices in an array where the k-length prefix is non-increasing and the k-length suffix is non-decreasing.

Medium
2424

Longest Uploaded Prefix

Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…

Medium
2425

Bitwise XOR of All Pairings

Compute the overall bitwise XOR from all pairings between two arrays using efficient array and bit manipulation techniqu…

Medium
2428

Maximum Sum of an Hourglass

Calculate the maximum sum of an hourglass in a 2D matrix using array traversal and submatrix evaluation techniques effic…

Medium
2429

Minimize XOR

Minimize XOR problem asks for an integer that minimizes XOR with another, applying greedy choices for bit manipulation.

Medium
2433

Find The Original Array of Prefix Xor

Find the original array from a given prefix XOR array using bitwise manipulation techniques.

Medium
2434

Using a Robot to Print the Lexicographically Smallest String

Solve the problem of using a robot to print the lexicographically smallest string with stack-based state management.

Medium
2438

Range Product Queries of Powers

The Range Product Queries of Powers problem requires calculating the product of powers of 2 for a range of queries on a …

Medium
2439

Minimize Maximum of Array

Minimize Maximum of Array involves finding the smallest possible maximum value after applying a series of operations on …

Medium
2442

Count Number of Distinct Integers After Reverse Operations

This problem requires counting distinct integers after performing reverse operations on each integer in an array.

Medium
2443

Sum of Number and Its Reverse

Determine if a non-negative integer can be expressed as the sum of a number and its reverse using enumeration and math r…

Medium
2447

Number of Subarrays With GCD Equal to K

Count the number of subarrays with GCD equal to a given value k from a list of integers.

Medium
2452

Words Within Two Edits of Dictionary

Identify all words in queries that can match dictionary entries with at most two character changes efficiently using arr…

Medium
2453

Destroy Sequential Targets

Find the minimum seed value to destroy the most targets on a number line, using array scanning and hash lookup.

Medium
2456

Most Popular Video Creator

Identify the most popular video creator by summing views and selecting their top-viewed video with array and hash patter…

Medium
2457

Minimum Addition to Make Integer Beautiful

Find the minimum addition to a number such that its digits sum to a value less than or equal to a given target.

Medium
2461

Maximum Sum of Distinct Subarrays With Length K

Find the maximum sum of all distinct-element subarrays of length k using array scanning and hash lookup techniques.

Medium
2462

Total Cost to Hire K Workers

Optimize the total cost of hiring exactly k workers using a two-pointer approach with invariant tracking and priority qu…

Medium
2466

Count Ways To Build Good Strings

Count the number of ways to build good binary strings using dynamic programming with state transitions.

Medium
2467

Most Profitable Path in a Tree

Solve the 'Most Profitable Path in a Tree' problem using graph traversal and depth-first search techniques to maximize A…

Medium
2470

Number of Subarrays With LCM Equal to K

Find the number of subarrays in an array where the least common multiple (LCM) of the subarray equals a given integer k.

Medium
2471

Minimum Number of Operations to Sort a Binary Tree by Level

Determine the minimum number of swaps to sort each level of a binary tree using level-wise traversal efficiently.

Medium
2476

Closest Nodes Queries in a Binary Search Tree

Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…

Medium
2477

Minimum Fuel Cost to Report to the Capital

Calculate the minimum fuel needed for all city representatives to reach the capital using DFS on a tree graph efficientl…

Medium
2482

Difference Between Ones and Zeros in Row and Column

This problem requires computing a difference matrix based on the ones and zeros in each row and column of a binary matri…

Medium
2483

Minimum Penalty for a Shop

Determine the earliest closing hour of a shop to minimize penalty using a string of customer visits and prefix sums.

Medium
2486

Append Characters to String to Make Subsequence

Determine the minimum characters to append to s so t becomes a subsequence using efficient two-pointer scanning techniqu…

Medium
2487

Remove Nodes From Linked List

This problem requires removing nodes from a linked list when a larger node exists to their right, testing pointer manipu…

Medium
2491

Divide Players Into Teams of Equal Skill

Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.

Medium
2492

Minimum Score of a Path Between Two Cities

Find the minimum distance in a path connecting two cities using graph traversal strategies efficiently.

Medium
2497

Maximum Star Sum of a Graph

Find the maximum star sum in a graph with specific node values and edges, using greedy algorithms to select the optimal …

Medium
2498

Frog Jump II

Frog Jump II requires finding the minimal maximum jump length for a frog to traverse stones forward and backward efficie…

Medium
2501

Longest Square Streak in an Array

Find the length of the longest subsequence where each element is a perfect square of its previous one.

Medium
2502

Design Memory Allocator

Design a memory allocator that simulates allocation and deallocation of memory blocks.

Medium
2507

Smallest Value After Replacing With Sum of Prime Factors

Replace a number with the sum of its prime factors until it stabilizes, and return the smallest value.

Medium
2512

Reward Top K Students

Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…

Medium
2513

Minimize the Maximum of Two Arrays

Minimize the Maximum of Two Arrays requires finding the smallest possible maximum number across two arrays, using binary…

Medium
2516

Take K of Each Character From Left and Right

Find the minimum number of minutes needed to take at least k of each character from both ends of a string.

Medium
2517

Maximum Tastiness of Candy Basket

Maximize the tastiness of a candy basket by choosing k candies from a list of candy prices.

Medium
2521

Distinct Prime Factors of Product of Array

Find the number of distinct prime factors in the product of an array of integers.

Medium
2522

Partition String Into Substrings With Values at Most K

Determine the minimum number of substrings from a numeric string such that each substring value does not exceed k using …

Medium
2523

Closest Prime Numbers in Range

Find the two closest prime numbers within a given range using efficient number theory techniques and gap comparisons.

Medium
2526

Find Consecutive Integers from a Data Stream

Design a data stream checker to identify consecutive integers from a stream, focusing on handling state transitions effi…

Medium
2527

Find Xor-Beauty of Array

Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.

Medium
2530

Maximal Score After Applying K Operations

Maximize your score by applying exactly k operations on an array using greedy selection and heap optimization techniques…

Medium
2531

Make Number of Distinct Characters Equal

Determine if a single swap can equalize distinct character counts between two strings using hash tables for tracking fre…

Medium
2536

Increment Submatrices by One

Increment Submatrices by One focuses on efficiently updating submatrices using row-wise prefix sums in an n by n matrix.

Medium
2537

Count the Number of Good Subarrays

Count the number of subarrays that contain at least k pairs of equal elements using array scanning and hash lookup.

Medium
2541

Minimum Operations to Make Array Equal II

Calculate the minimum operations to make two integer arrays equal using greedy adjustments with modular checks efficient…

Medium
2542

Maximum Subsequence Score

Maximize the score of a subsequence by selecting indices based on nums1 and nums2, using a greedy approach and sorting.

Medium
2545

Sort the Students by Their Kth Score

Sort a matrix of student scores by the kth exam efficiently using array manipulation and custom sorting techniques.

Medium
2546

Apply Bitwise Operations to Make Strings Equal

Determine if a binary string s can be transformed into target using repeated bitwise operations on paired indices effici…

Medium
2550

Count Collisions of Monkeys on a Polygon

Calculate the total number of monkey collisions on a convex polygon using math and recursion efficiently for large n.

Medium
2554

Maximum Number of Integers to Choose From a Range I

Determine the maximum count of integers from 1 to n avoiding banned numbers while keeping the sum under maxSum.

Medium
2555

Maximize Win From Two Segments

Maximize the total prizes by choosing two segments of length k on a sorted line of prize positions efficiently using bin…

Medium
2556

Disconnect Path in a Binary Matrix by at Most One Flip

Determine if a single cell flip can disconnect a path from the top-left to bottom-right in a binary matrix efficiently u…

Medium
2559

Count Vowel Strings in Ranges

Count the number of strings that start and end with a vowel in given ranges within an array of words.

Medium
2560

House Robber IV

House Robber IV requires calculating minimum maximum money the robber can take using state transition dynamic programmin…

Medium
2563

Count the Number of Fair Pairs

Efficiently count all fair pairs in an array using sorting and binary search, focusing on the sum range between lower an…

Medium
2564

Substring XOR Queries

Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…

Medium
2567

Minimum Score by Changing Two Elements

The problem asks for the minimum score after changing two elements of an array using a greedy approach.

Medium
2568

Minimum Impossible OR

Find the smallest positive integer that cannot be formed from any subsequence OR combination in the array.

Medium
2571

Minimum Operations to Reduce an Integer to 0

Compute the minimum number of operations to reduce a positive integer to zero using additions or subtractions of powers …

Medium
2572

Count the Number of Square-Free Subsets

Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…

Medium
2575

Find the Divisibility Array of a String

Calculate the divisibility array for a string by checking if prefixes are divisible by a given number.

Medium
2576

Find the Maximum Number of Marked Indices

Maximize marked indices in an array by performing allowed operations, applying binary search to find the optimal count e…

Medium
2579

Count Total Number of Colored Cells

The "Count Total Number of Colored Cells" problem requires deriving a formula to compute colored cells based on elapsed …

Medium
2580

Count Ways to Group Overlapping Ranges

Count Ways to Group Overlapping Ranges is a medium difficulty problem focused on array manipulation and sorting to count…

Medium
2583

Kth Largest Sum in a Binary Tree

Find the kth largest level sum in a binary tree using level-order traversal and sorting.

Medium
2587

Rearrange Array to Maximize Prefix Score

Maximize the number of positive prefix sums by rearranging an integer array using a greedy, order-focused strategy.

Medium
2588

Count the Number of Beautiful Subarrays

Count the Number of Beautiful Subarrays is a Medium-level problem involving array scanning and hash table lookup to find…

Medium
2592

Maximize Greatness of an Array

Maximize Greatness of an Array requires permuting numbers to exceed original values at most indices efficiently.

Medium
2593

Find Score of an Array After Marking All Elements

The problem involves marking elements in an array and calculating the score based on adjacent elements.

Medium
2594

Minimum Time to Repair Cars

Find the minimum time to repair all cars using mechanics with different ranks, applying binary search over possible time…

Medium
2596

Check Knight Tour Configuration

Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.

Medium
2597

The Number of Beautiful Subsets

Count all non-empty subsets of an array where no two numbers have an absolute difference equal to k, using array scannin…

Medium
2598

Smallest Missing Non-negative Integer After Operations

Find the smallest missing non-negative integer after repeated additions or subtractions of a given value in nums array e…

Medium
2601

Prime Subtraction Operation

Determine if it's possible to make the array strictly increasing using prime subtractions.

Medium
2602

Minimum Operations to Make All Array Elements Equal

Find the minimum number of operations to make all elements in an array equal for each query.

Medium
2606

Find the Substring With Maximum Cost

Find the Substring With Maximum Cost requires calculating substring values using a hash lookup for character costs, with…

Medium
2607

Make K-Subarray Sums Equal

Solve Make K-Subarray Sums Equal by grouping circular indices with gcd cycles and minimizing each group to its median.

Medium
2610

Convert an Array Into a 2D Array With Conditions

Learn how to convert an integer array into a 2D array with distinct rows using array scanning plus hash lookup efficient…

Medium
2611

Mice and Cheese

In 'Mice and Cheese', you must maximize the total reward of two mice eating cheese while respecting their preferences an…

Medium
2615

Sum of Distances

In this problem, you calculate an array where each element is the sum of absolute differences of indices for equal value…

Medium
2616

Minimize the Maximum Difference of Pairs

Minimize the Maximum Difference of Pairs seeks to optimize the maximum pairwise difference in a set of index pairs from …

Medium
2618

Check if Object Instance of Class

Implement a function to check if an object is an instance of a specific class or its superclass in JavaScript.

Medium
2622

Cache With Time Limit

Implement a time-limited cache where keys expire after a given duration, with operations to set, get, and count active k…

Medium
2623

Memoize

This problem focuses on creating a memoized function that caches results to prevent repeated computation with identical …

Medium
2624

Snail Traversal

Transform a 1D array into a 2D matrix following the snail traversal core interview pattern efficiently and safely.

Medium
2625

Flatten Deeply Nested Array

Flatten Deeply Nested Array involves transforming multi-dimensional arrays based on depth constraints, requiring a caref…

Medium
2627

Debounce

Create a debounced function that delays execution and cancels previous calls within a time window.

Medium
2631

Group By

Implementing the Group By core interview pattern efficiently sorts array elements into keyed groups based on a selector …

Medium
2637

Promise Time Limit

Implement a time-limited wrapper for any asynchronous function to enforce execution constraints and prevent overruns.

Medium
2640

Find the Score of All Prefixes of an Array

Compute the score of each prefix in an array using conversion rules while tracking the maximum efficiently for prefix su…

Medium
2641

Cousins in Binary Tree II

Replace each node in a binary tree with the sum of all its cousins by carefully tracking depth and parent relationships.

Medium
2645

Minimum Additions to Make Valid String

Determine the minimum insertions required to transform a given string into repeated concatenations of 'abc' using dynami…

Medium
2649

Nested Array Generator

Implement a generator that performs inorder traversal on a multi-dimensional array of integers.

Medium
2653

Sliding Subarray Beauty

Compute the xth smallest negative number in each sliding subarray using array scanning and hash frequency tracking effic…

Medium
2654

Minimum Number of Operations to Make All Array Elements Equal to 1

Find the minimum number of operations to transform every element of a positive integer array into 1 using gcd operations…

Medium
2657

Find the Prefix Common Array of Two Arrays

This problem challenges you to find the prefix common array of two integer permutations, utilizing array scanning and ha…

Medium
2658

Maximum Number of Fish in a Grid

Maximize the number of fish that can be caught by performing DFS on an optimal starting point in a grid.

Medium
2661

First Completely Painted Row or Column

Find the first index where a row or column is completely painted in a matrix based on an array of integers.

Medium
2662

Minimum Cost of a Path With Special Roads

Find the minimum cost path between two points, using special roads or direct moves in a 2D space.

Medium
2671

Frequency Tracker

Design a data structure to track values and answer frequency-related queries efficiently using hash tables.

Medium
2672

Number of Adjacent Elements With the Same Color

Calculate the number of adjacent elements sharing the same color after sequentially updating an initially zeroed array u…

Medium
2673

Make Costs of Paths Equal in a Binary Tree

Minimize the cost increments required to equalize path costs in a binary tree from root to leaves.

Medium
2679

Sum in a Matrix

Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…

Medium
2680

Maximum OR

Maximize the bitwise OR of an array by applying at most k multiplication operations on selected elements.

Medium
2683

Neighboring Bitwise XOR

Determine if a binary array original exists that produces the given derived array using neighboring bitwise XOR logic.

Medium
2684

Maximum Number of Moves in a Grid

Maximize the number of moves in a grid starting from the first column using state transition dynamic programming.

Medium
2685

Count the Number of Complete Components

Determine the number of complete connected components in an undirected graph using efficient traversal techniques and gr…

Medium
2693

Call Function with Custom Context

Learn to implement a callPolyfill method that correctly sets a function's this context and passes arguments properly.

Medium
2694

Event Emitter

Design an EventEmitter class that can subscribe, emit, and unsubscribe events, mimicking patterns seen in Node.js or DOM…

Medium
2698

Find the Punishment Number of an Integer

Find the punishment number of a given integer using backtracking search with pruning.

Medium
2705

Compact Object

Compact Object requires removing all falsy values from an object or array recursively to produce a clean, minimal struct…

Medium
2707

Extra Characters in a String

The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…

Medium
2708

Maximum Strength of a Group

Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…

Medium
2711

Difference of Number of Distinct Values on Diagonals

Find the difference in the number of distinct diagonal values in a matrix, returning results in a new matrix.

Medium
2712

Minimum Cost to Make All Characters Equal

Find the minimum cost to make all characters of a binary string equal by performing two types of operations.

Medium
2718

Sum of Matrix After Queries

Calculate the total sum of a zero-filled n x n matrix after sequentially applying row and column update queries efficien…

Medium
2721

Execute Asynchronous Functions in Parallel

Solve the problem of executing asynchronous functions in parallel, handling resolve and reject scenarios effectively.

Medium
2722

Join Two Arrays by ID

Merge two arrays of objects by their id keys, resolving conflicts with arr2 values and sorting by id ascending.

Medium
2730

Find the Longest Semi-Repetitive Substring

Find the length of the longest substring where at most one adjacent pair of digits repeats, using a sliding window appro…

Medium
2731

Movement of Robots

Calculate total distances between robots moving on a number line while accounting for collisions using array plus braint…

Medium
2734

Lexicographically Smallest String After Substring Operation

Given a string, perform operations to make it lexicographically smaller using a greedy approach with substring modificat…

Medium
2735

Collecting Chocolates

Calculate the minimum cost to collect all chocolate types using rotations and purchases in an array-based enumeration pa…

Medium
2740

Find the Value of the Partition

Find the minimum partition value by dividing a positive integer array into two subarrays using sorting for efficiency.

Medium
2741

Special Permutations

Count the number of special permutations for a given array using dynamic programming and bit manipulation.

Medium
2745

Construct the Longest New String

Maximize the length of a string built from AA, BB, and AB without creating triple repeats using DP and greedy logic.

Medium
2746

Decremental String Concatenation

Solve the Decremental String Concatenation problem by applying dynamic programming to minimize string length after conca…

Medium
2747

Count Zero Request Servers

Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…

Medium
2749

Minimum Operations to Make the Integer Zero

This problem challenges you to compute the minimum operations to reduce an integer to zero using bit manipulation and st…

Medium
2750

Ways to Split Array Into Good Subarrays

Calculate the number of ways to partition a binary array into good subarrays using state transition dynamic programming …

Medium
2761

Prime Pairs With Target Sum

Find all prime number pairs that sum up to a given integer n using an efficient sieve-based array approach.

Medium
2762

Continuous Subarrays

Count all continuous subarrays efficiently using sliding window with running max-min state tracking for array consistenc…

Medium
2766

Relocate Marbles

Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.

Medium
2767

Partition String Into Minimum Beautiful Substrings

Partition a binary string into the fewest beautiful substrings using state transition dynamic programming and careful su…

Medium
2768

Number of Black Blocks

Calculate the number of black blocks in a grid given a list of black cell coordinates.

Medium
2770

Maximum Number of Jumps to Reach the Last Index

Find the maximum number of jumps to reach the last index using state transition dynamic programming efficiently in array…

Medium
2771

Longest Non-decreasing Subarray From Two Arrays

Maximize the length of a non-decreasing subarray by optimally choosing elements from two arrays using dynamic programmin…

Medium
2772

Apply Operations to Make All Array Elements Equal to Zero

Determine if all elements in a given array can be reduced to zero using repeated k-length prefix operations efficiently.

Medium
2779

Maximum Beauty of an Array After Applying Operation

Find the maximum beauty of an array by adjusting elements within a range using binary search and sliding window techniqu…

Medium
2780

Minimum Index of a Valid Split

Find the minimum index to split an array such that both subarrays have the same dominant element.

Medium
2785

Sort Vowels in a String

Sort Vowels in a String requires identifying vowels in a string and rearranging them in ascending order while keeping co…

Medium
2786

Visit Array Positions to Maximize Score

Maximize your score by visiting positions in an array while handling penalties for parity changes efficiently with DP.

Medium
2787

Ways to Express an Integer as Sum of Powers

Compute the number of ways to express an integer as a sum of unique powers using state transition dynamic programming ef…

Medium
2789

Largest Element in an Array after Merge Operations

This problem focuses on applying greedy choices and merging elements to find the largest element in an array.

Medium
2799

Count Complete Subarrays in an Array

Count Complete Subarrays in an Array requires scanning the array while tracking elements to detect subarrays with all di…

Medium
2800

Shortest String That Contains Three Strings

Find the shortest string containing three given strings using a greedy approach while ensuring it is lexicographically s…

Medium
2807

Insert Greatest Common Divisors in Linked List

The problem involves inserting greatest common divisors between adjacent nodes in a linked list.

Medium
2808

Minimum Seconds to Equalize a Circular Array

Find the minimum number of seconds to equalize a circular array using array scanning and hash lookup techniques.

Medium
2811

Check if it is Possible to Split Array

Determine whether an array can be fully split into single-element subarrays using a state transition dynamic programming…

Medium
2812

Find the Safest Path in a Grid

Find the Safest Path in a Grid uses binary search and BFS to maximize path safeness from thieves in a grid.

Medium
2816

Double a Number Represented as a Linked List

Double a number represented as a linked list by carefully managing node values and carries with pointer traversal techni…

Medium
2817

Minimum Absolute Difference Between Elements With Constraint

Find the minimum absolute difference between two array elements that are at least x indices apart using binary search.

Medium
2825

Make String a Subsequence Using Cyclic Increments

Determine if str2 can be made a subsequence of str1 by incrementing characters cyclically using at most one operation.

Medium
2826

Sorting Three Groups

Determine the minimum removals to make an array of 1s, 2s, and 3s non-decreasing using dynamic programming transitions.

Medium
2829

Determine the Minimum Sum of a k-avoiding Array

Determine the minimum sum of a k-avoiding array by choosing distinct integers such that no pair sums to a given k.

Medium
2830

Maximize the Profit as the Salesman

Determine the maximum profit a salesman can earn by strategically selecting non-overlapping offers on consecutive houses…

Medium
2831

Find the Longest Equal Subarray

Find the maximum length of an equal subarray after removing up to k elements using array scanning and hash-based index t…

Medium
2834

Find the Minimum Possible Sum of a Beautiful Array

Find the minimum possible sum of a beautiful array that satisfies the given conditions with the greedy approach.

Medium
2840

Check if Strings Can be Made Equal With Operations II

Check if two strings can be made equal using operations that swap characters with the same parity.

Medium
2841

Maximum Sum of Almost Unique Subarray

Find the maximum sum of subarrays that contain at least m distinct elements using array scanning and hash lookups effici…

Medium
2844

Minimum Operations to Make a Special Number

Minimize operations to make a number divisible by 25 by deleting digits. Use greedy choice and invariant validation.

Medium
2845

Count of Interesting Subarrays

Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …

Medium
2849

Determine if a Cell Is Reachable at a Given Time

The problem asks if a target cell can be reached from a starting position within a given time on a 2D grid.

Medium
2850

Minimum Moves to Spread Stones Over Grid

Solve the problem of distributing 9 stones across a 3x3 grid with minimal moves using state transition dynamic programmi…

Medium
2856

Minimum Array Length After Pair Removals

This problem involves minimizing the length of a sorted array by repeatedly removing adjacent pairs of equal elements.

Medium
2857

Count Pairs of Points With Distance k

Solve the problem of counting pairs of points with distance k using array scanning and hash table techniques.

Medium
2860

Happy Students

The Happy Students problem asks how many ways a teacher can select a group of students so everyone is happy, based on ce…

Medium
2861

Maximum Number of Alloys

Determine the maximum number of alloys possible using limited metal stock and budget, leveraging binary search efficient…

Medium
2865

Beautiful Towers I

Solve Beautiful Towers I by testing each peak and enforcing mountain limits with monotonic stack style height propagatio…

Medium
2866

Beautiful Towers II

Maximize tower configurations with the stack-based approach while ensuring mountain-like patterns in this medium difficu…

Medium
2870

Minimum Number of Operations to Make Array Empty

Minimize the number of operations to make an array empty by leveraging array scanning and hash lookup.

Medium
2871

Split Array Into Maximum Number of Subarrays

Maximize the number of subarrays in an array while ensuring each subarray's bitwise AND meets the minimum score requirem…

Medium
2874

Maximum Value of an Ordered Triplet II

Solve Maximum Value of an Ordered Triplet II in linear time by tracking the best left difference and right multiplier.

Medium
2875

Minimum Size Subarray in Infinite Array

Find the shortest subarray in an infinite array that sums to a given target using array scanning and hash lookup.

Medium
2895

Minimum Processing Time

Determine the minimum total processing time by optimally assigning tasks to multiple processors using a greedy approach.

Medium
2896

Apply Operations to Make Two Strings Equal

Apply Operations to Make Two Strings Equal involves transforming binary strings with a cost-based dynamic programming ap…

Medium
2901

Longest Unequal Adjacent Groups Subsequence II

Find the longest subsequence of indices such that the corresponding strings have a valid Hamming distance and group cons…

Medium
2904

Shortest and Lexicographically Smallest Beautiful String

Find the shortest beautiful substring in a binary string and return the lexicographically smallest option efficiently us…

Medium
2905

Find Indices With Index and Value Difference II

Locate two indices in an array where both index and value differences meet specified thresholds using precise scanning t…

Medium
2906

Construct Product Matrix

Solve the "Construct Product Matrix" problem by calculating the product of elements in 2D matrices without division.

Medium
2909

Minimum Sum of Mountain Triplets II

Find the minimum sum of a valid mountain triplet in an integer array, or return -1 if no valid triplet exists.

Medium
2910

Minimum Number of Groups to Create a Valid Assignment

The problem involves sorting balls into boxes while minimizing the number of boxes, adhering to size constraints.

Medium
2914

Minimum Number of Changes to Make Binary String Beautiful

This problem involves determining the minimum number of changes to make a binary string beautiful using string-driven st…

Medium
2915

Length of the Longest Subsequence That Sums to Target

Find the length of the longest subsequence in an array that sums to a target value, using dynamic programming.

Medium
2918

Minimum Equal Sum of Two Arrays After Replacing Zeros

Find the minimum sum where two arrays become equal after replacing all zeros with positive integers using a greedy strat…

Medium
2919

Minimum Increment Operations to Make Array Beautiful

Optimize the number of increment operations to make an array beautiful by ensuring subarrays of size 3 or more meet the …

Medium
2924

Find Champion II

Identify the strongest team in a tournament DAG using graph-driven logic, ensuring correct handling of in-degree zero ch…

Medium
2925

Maximum Score After Applying Operations on a Tree

Solve Maximum Score After Applying Operations on a Tree by turning healthy-path constraints into subtree DP and forced-v…

Medium
2929

Distribute Candies Among Children II

Determine how to distribute n candies among 3 children without exceeding a limit on individual candies.

Medium
2930

Number of Strings Which Can Be Rearranged to Contain Substring

Calculate how many strings of length n can be rearranged to contain "leet" using dynamic programming and combinatorics.

Medium
2933

High-Access Employees

Identify employees with high system access within one-hour periods based on access logs.

Medium
2934

Minimum Operations to Maximize Last Elements in Arrays

Minimize the number of operations needed to maximize the last elements of two arrays with specific swaps.

Medium
2938

Separate Black and White Balls

Solve the "Separate Black and White Balls" problem by swapping adjacent balls to group all black balls to the right with…

Medium
2939

Maximum Xor Product

Find the maximum value of (a XOR x) * (b XOR x) using greedy bitwise choices and invariant validation.

Medium
2943

Maximize Area of Square Hole in Grid

Learn how to maximize the area of a square-shaped hole by selectively removing horizontal and vertical bars efficiently …

Medium
2944

Minimum Number of Coins for Fruits

Calculate the minimum coins to buy fruits using state transition dynamic programming while handling rewards and purchase…

Medium
2947

Count Beautiful Substrings I

Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.

Medium
2948

Make Lexicographically Smallest Array by Swapping Elements

Solve the problem of making an array lexicographically smallest through element swaps under a limit constraint.

Medium
2952

Minimum Number of Coins to be Added

Determine the minimum number of coins to add so all values up to target are obtainable using a greedy sum approach.

Medium
2957

Remove Adjacent Almost-Equal Characters

Minimize operations to remove adjacent almost-equal characters using dynamic programming and greedy methods.

Medium
2958

Length of Longest Subarray With at Most K Frequency

Find the maximum length subarray where each number appears at most k times using array scanning and hash lookups.

Medium
2961

Double Modular Exponentiation

Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…

Medium
2962

Count Subarrays Where Max Element Appears at Least K Times

Find the number of subarrays where the maximum element appears at least k times using a sliding window approach.

Medium
2966

Divide Array Into Arrays With Max Difference

Divide an array into subarrays with a maximum element difference under a given threshold using a greedy approach.

Medium
2967

Minimum Cost to Make Array Equalindromic

Determine the minimum cost to convert an integer array into a palindromic array using allowed element modifications effi…

Medium
2971

Find Polygon With the Largest Perimeter

Determine the largest perimeter polygon from a set of side lengths using a greedy approach with invariant validation che…

Medium
2975

Maximum Square Area by Removing Fences From a Field

This problem challenges you to calculate the largest square area possible by removing fences from a given rectangular fi…

Medium
2976

Minimum Cost to Convert String I

This problem asks to calculate the minimum cost to convert a string from source to target using specific character trans…

Medium
2981

Find Longest Special Substring That Occurs Thrice I

Find the longest special substring in a string that appears at least three times, or return -1 if no such substring exis…

Medium
2982

Find Longest Special Substring That Occurs Thrice II

Find the longest special substring that occurs at least three times in a given string using binary search and hash table…

Medium
2997

Minimum Number of Operations to Make Array XOR Equal to K

Find the minimum number of operations to make the XOR of an array equal to a given value k by modifying array elements.

Medium
2998

Minimum Number of Operations to Make X and Y Equal

Determine the minimum operations to make two integers equal using increment, decrement, and division efficiently with DP…

Medium
3001

Minimum Moves to Capture The Queen

Determine the fewest moves to capture the black queen using only white pieces with careful position analysis.

Medium
3002

Maximum Size of a Set After Removals

Maximize a set size by strategically removing half of elements from two arrays using hash lookups and array scanning.

Medium
3006

Find Beautiful Indices in the Given Array I

Identify all beautiful indices where substring a appears and a nearby substring b exists within distance k efficiently.

Medium
3007

Maximum Number That Sum of the Prices Is Less Than or Equal to K

Find the greatest number whose accumulated price, based on binary set bit positions, is less than or equal to k.

Medium
3011

Find if Array Can Be Sorted

Determine if a given array can be sorted using adjacent swaps restricted by equal set bits in binary representation.

Medium
3012

Minimize Length of Array Using Operations

Minimize the length of an integer array through a series of operations, using a greedy approach with modular arithmetic.

Medium
3015

Count the Number of Houses at a Certain Distance I

Determine the number of house pairs at each street distance using graph traversal and breadth-first search efficiently.

Medium
3016

Minimum Number of Pushes to Type Word II

Given a word, find the minimum number of pushes to type it on a remapped keypad using a greedy approach.

Medium
3020

Find the Maximum Number of Elements in Subset

This problem asks you to find the maximum subset size where each number in the subset follows a specific pattern with ha…

Medium
3021

Alice and Bob Playing Flower Game

Alice and Bob play a turn-based game on a circular field with flowers, where players must choose pairs that satisfy pari…

Medium
3025

Find the Number of Ways to Place People I

Calculate how many valid pairs of points can be formed on a 2D plane using array and math enumeration techniques efficie…

Medium
3026

Maximum Good Subarray Sum

Find the maximum sum of any subarray where the first and last elements differ by exactly k using efficient array scannin…

Medium
3029

Minimum Time to Revert Word to Initial State I

Determine the minimum seconds to revert a string to its original state using repeated prefix shifts of length k efficien…

Medium
3030

Find the Grid of Region Average

Find the Grid of Region Average requires identifying regions in a matrix where pixel differences are below a threshold, …

Medium
3034

Number of Subarrays That Match a Pattern I

Count all subarrays in a given integer array that strictly follow a defined numeric pattern using rolling hash checks ef…

Medium
3035

Maximum Palindromes After Operations

The problem focuses on maximizing the number of palindromes that can be formed from a given list of words through specif…

Medium
3039

Apply Operations to Make String Empty

Learn how to systematically apply operations on a string using array scanning and hash lookups to reduce it efficiently.

Medium
3040

Maximum Number of Operations With the Same Score II

This problem asks to maximize operations on an integer array where all deletions produce the same score using dynamic pr…

Medium
3043

Find the Length of the Longest Common Prefix

Determine the length of the longest common prefix between two integer arrays using array scanning and hash lookup effici…

Medium
3044

Most Frequent Prime

Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…

Medium
3047

Find the Largest Area of Square Inside Two Rectangles

Find the largest square area that can fit inside the intersection of two or more rectangles in a 2D plane.

Medium
3048

Earliest Second to Mark Indices I

The problem asks to determine the earliest second to mark all indices in an array using a set of operations.

Medium
3066

Minimum Operations to Exceed Threshold Value II

Calculate the fewest operations to make every array element exceed a threshold using a min-heap simulation strategy effi…

Medium
3067

Count Pairs of Connectable Servers in a Weighted Tree Network

This problem involves counting pairs of connectable servers in a weighted tree network using binary-tree traversal and D…

Medium
3070

Count Submatrices with Top-Left Element and Sum Less Than k

Count all submatrices including the top-left element with sum less than k using array and matrix prefix sum strategies.

Medium
3071

Minimum Operations to Write the Letter Y on a Grid

Find the minimum number of operations to write the letter Y on a grid by altering cell values.

Medium
3075

Maximize Happiness of Selected Children

Maximize the happiness of selected children by choosing the k happiest ones and applying greedy strategies to minimize l…

Medium
3076

Shortest Uncommon Substring in an Array

Find the shortest substring for each string in an array that does not appear in any other string efficiently using hashi…

Medium
3080

Mark Elements on Array by Performing Queries

Efficiently mark elements in an array based on queries using scanning plus hash lookup to track marked indices and compu…

Medium
3081

Replace Question Marks in String to Minimize Its Value

Minimize the cost of a string with '?' characters by replacing them with letters in lexicographical order while minimizi…

Medium
3084

Count Substrings Starting and Ending with Given Character

Given a string and a character, find the total number of substrings that start and end with that character.

Medium
3085

Minimum Deletions to Make String K-Special

Minimize deletions to make a string k-special by adjusting character frequencies.

Medium
3091

Apply Operations to Make Sum of Array Greater Than or Equal to k

Given an array nums, find the minimum number of operations to make the sum of elements greater than or equal to k.

Medium
3092

Most Frequent IDs

Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.

Medium
3096

Minimum Levels to Gain More Points

Determine the minimum number of levels Alice must play in a binary game array to secure more points than Bob using prefi…

Medium
3097

Shortest Subarray With OR at Least K II

Find the length of the shortest subarray where the bitwise OR of all its elements is at least a given value.

Medium
3100

Water Bottles II

Compute the maximum number of water bottles you can drink by simulating exchanges with step-by-step math logic.

Medium
3101

Count Alternating Subarrays

Count all alternating subarrays in a binary array efficiently using array patterns and simple mathematical reasoning.

Medium
3106

Lexicographically Smallest String After Operations With Constraint

Minimize a string lexicographically using a series of operations constrained by a given integer k.

Medium
3107

Minimum Operations to Make Median of Array Equal to K

The problem involves minimizing operations to make the median of an array equal to a given value k using a greedy approa…

Medium
3111

Minimum Rectangles to Cover Points

Find the minimum number of rectangles needed to cover all points, given constraints on width and position.

Medium
3112

Minimum Time to Visit Disappearing Nodes

Determine the minimum time to visit each node in a disappearing-node graph using arrays, graphs, and priority queues eff…

Medium
3115

Maximum Prime Difference

Calculate the largest index gap between prime numbers in an array using array traversal and number theory insights effic…

Medium
3121

Count the Number of Special Characters II

Count the Number of Special Characters II is a medium difficulty string and hash table problem that involves identifying…

Medium
3122

Minimum Number of Operations to Satisfy Conditions

This problem asks to find the minimum number of operations on a 2D grid using state transition dynamic programming effic…

Medium
3128

Right Triangles

Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.

Medium
3129

Find All Possible Stable Binary Arrays I

Find all stable binary arrays of a given number of 0's, 1's, and limit using dynamic programming and state transitions.

Medium
3132

Find the Integer Added to Array II

Given two arrays nums1 and nums2, determine the integer added to nums1 to make it equal to nums2 after removing two elem…

Medium
3133

Minimum Array End

Construct an array where elements are greater than the previous one, and the bitwise AND of all elements equals a given …

Medium
3137

Minimum Number of Operations to Make Word K-Periodic

The problem requires calculating the minimum number of operations to make a string k-periodic using specific substring r…

Medium
3138

Minimum Length of Anagram Concatenation

The problem asks to find the minimum length of a string t such that s is a concatenation of anagrams of t.

Medium
3143

Maximum Points Inside the Square

Find the maximum number of points inside a valid square centered at the origin using a scanning and hashing approach.

Medium
3144

Minimum Substring Partition of Equal Character Frequency

Partition a string into substrings with equal character frequencies using dynamic programming and state transitions.

Medium
3147

Taking Maximum Energy From the Mystic Dungeon

Maximize your energy by strategically jumping through magicians using array and prefix sum techniques for optimal path c…

Medium
3148

Maximum Difference Score in a Grid

Maximize the score in a grid by making moves to the bottom or right, using state transition dynamic programming.

Medium
3152

Special Array II

Determine whether each subarray meets the special condition of alternating parity for all adjacent elements efficiently …

Medium
3153

Sum of Digit Differences of All Pairs

Sum of Digit Differences of All Pairs is a problem that involves counting digit differences in pairs from an array of in…

Medium
3159

Find Occurrences of an Element in an Array

Determine the position of each requested occurrence of x in nums using a hash table and efficient array scanning.

Medium
3160

Find the Number of Distinct Colors Among the Balls

Efficiently track colors on balls using array scanning and hash lookup to return the count of distinct colors after each…

Medium
3163

String Compression III

Compress a string by repeatedly taking maximal same-character prefixes, following a string-driven solution strategy effi…

Medium
3164

Find the Number of Good Pairs II

Calculate total good pairs by scanning two arrays and using hash lookup to match divisible elements efficiently with k.

Medium
3169

Count Days Without Meetings

Count Days Without Meetings is a problem where you need to count days without scheduled meetings in a given work period.

Medium
3170

Lexicographically Minimum String After Removing Stars

Find the lexicographically smallest string by removing stars using stack-based state management and careful character se…

Medium
3175

Find The First Player to win K Games in a Row

Determine which player first wins k consecutive games using array simulation logic to track ongoing victories efficientl…

Medium
3176

Find the Maximum Length of a Good Subsequence I

Find the maximum length of a good subsequence by scanning arrays and using hash lookups for value remapping efficiently.

Medium
3179

Find the N-th Value After K Seconds

Solve for the N-th value after K seconds by simulating array updates and using prefix sum techniques.

Medium
3180

Maximum Total Reward Using Operations I

Optimize the total reward by choosing operations on array indices using state transition dynamic programming techniques …

Medium
3185

Count Pairs That Form a Complete Day II

Count the number of valid pairs of hours that form a complete day by checking if their sum is a multiple of 24.

Medium
3186

Maximum Total Damage With Spell Casting

Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…

Medium
3191

Minimum Operations to Make Binary Array Elements Equal to One I

Find the minimum number of operations to make all elements of a binary array equal to one using sliding window and state…

Medium
3192

Minimum Operations to Make Binary Array Elements Equal to One II

Solve the Minimum Operations to Make Binary Array Elements Equal to One II using state transition dynamic programming ef…

Medium
3195

Find the Minimum Area to Cover All Ones I

Find the smallest rectangle to cover all 1's in a 2D binary matrix, focusing on array and matrix handling.

Medium
3196

Maximize Total Cost of Alternating Subarrays

Maximize the total cost of alternating subarrays using dynamic programming to efficiently split an array into optimal su…

Medium
3201

Find the Maximum Length of Valid Subsequence I

Find the longest valid subsequence in an array of integers using dynamic programming to handle different patterns of seq…

Medium
3202

Find the Maximum Length of Valid Subsequence II

Determine the maximum length of a valid subsequence using state transition dynamic programming with careful modulo const…

Medium
3207

Maximum Points After Enemy Battles

Solve the "Maximum Points After Enemy Battles" problem by maximizing points through greedy choices with energy validatio…

Medium
3208

Alternating Groups II

Solve the problem of counting alternating groups in a circle of tiles using a sliding window approach.

Medium
3211

Generate Binary Strings Without Adjacent Zeros

Generate all binary strings of length n without adjacent zeros using backtracking search with pruning for efficient enum…

Medium
3212

Count Submatrices With Equal Frequency of X and Y

Count the number of submatrices with equal frequency of 'X' and 'Y' in a 2D character grid.

Medium
3217

Delete Nodes From Linked List Present in Array

Remove nodes from a linked list if their values exist in a given array.

Medium
3218

Minimum Cost for Cutting Cake I

In this problem, you need to minimize the cost of cutting a cake into 1x1 pieces using vertical and horizontal cuts.

Medium
3223

Minimum Length of String After Operations

Find the minimum length of a string after performing operations based on character frequency.

Medium
3224

Minimum Array Changes to Make Differences Equal

Minimize changes to make array differences equal by replacing elements within a given range.

Medium
3227

Vowels Game in a String

Solve the Vowels Game in a String using optimal moves and string analysis to predict the winner efficiently and accurate…

Medium
3228

Maximum Number of Operations to Move Ones to the End

This problem requires finding the maximum number of operations to move ones to the end of a binary string.

Medium
3233

Find the Count of Numbers Which Are Not Special

Count the numbers between two integers that are not special, where special numbers are squares of primes.

Medium
3234

Count the Number of Substrings With Dominant Ones

Count the number of substrings in a binary string with dominant ones, using a sliding window approach with state updates…

Medium
3239

Minimum Number of Flips to Make Binary Grid Palindromic I

Find the minimum flips to make a binary grid palindromic by scanning with two pointers and tracking symmetry efficiently…

Medium
3240

Minimum Number of Flips to Make Binary Grid Palindromic II

The problem asks to flip cells in a binary grid to make its rows and columns palindromic using the minimum number of fli…

Medium
3243

Shortest Distance After Road Addition Queries I

Solve shortest paths dynamically in a growing graph using BFS, updating distances efficiently after each road addition q…

Medium
3249

Count the Number of Good Nodes

Determine how many nodes in a binary tree have all child subtrees of equal size using DFS traversal efficiently.

Medium
3254

Find the Power of K-Size Subarrays I

Given an array, find the power of all subarrays of size k using a sliding window approach.

Medium
3255

Find the Power of K-Size Subarrays II

Compute the power of all k-size subarrays in an array using sliding window with running state updates efficiently.

Medium
3259

Maximum Energy Boost From Two Drinks

Maximize energy boost from two drinks with a state transition dynamic programming approach.

Medium
3265

Count Almost Equal Pairs I

Count Almost Equal Pairs I involves finding pairs of elements that can be made equal by swapping at most one digit.

Medium
3271

Hash Divided String

Hash Divided String requires splitting a string into equal parts and combining character values modulo 26 to form a new …

Medium
3275

K-th Nearest Obstacle Queries

Solve the K-th nearest obstacle query problem using array and heap (priority queue) techniques to find distances efficie…

Medium
3281

Maximize Score of Numbers in Ranges

Maximize Score of Numbers in Ranges asks to find the maximum score by selecting integers within given intervals with a f…

Medium
3282

Reach End of Array With Max Score

Calculate the maximum score to reach the end of an array using greedy jumps based on array values and distances.

Medium
3286

Find a Safe Walk Through a Grid

Determine if you can safely traverse a binary grid from top-left to bottom-right using limited health points.

Medium
3290

Maximum Multiplication Score

The problem requires selecting four indices from an array to maximize a dynamic score with a transition approach.

Medium
3291

Minimum Number of Valid Strings to Form Target I

Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…

Medium
3295

Report Spam Message

Determine if a message contains at least two banned words using array scanning and hash lookup.

Medium
3296

Minimum Number of Seconds to Make Mountain Height Zero

Determine the minimum seconds required to reduce a mountain to zero height using simultaneous workers efficiently.

Medium
3297

Count Substrings That Can Be Rearranged to Contain a String I

Count the number of valid substrings in word1 that can be rearranged to contain word2 as a prefix.

Medium
3301

Maximize the Total Height of Unique Towers

Assign heights to towers ensuring each height is unique and the total sum is maximized using greedy sorting techniques.

Medium
3302

Find the Lexicographically Smallest Valid Sequence

Determine the lexicographically smallest valid index sequence by using state transition dynamic programming over word1 a…

Medium
3305

Count of Substrings Containing Every Vowel and K Consonants I

Count all substrings containing every vowel and exactly k consonants using a sliding window and hash map state tracking.

Medium
3306

Count of Substrings Containing Every Vowel and K Consonants II

Count the number of substrings containing all vowels and exactly k consonants using a sliding window technique.

Medium
3309

Maximum Possible Number by Binary Concatenation

Determine the largest number achievable by reordering three integers and concatenating their binary forms efficiently.

Medium
3310

Remove Methods From Project

Remove suspicious methods in a project that are invoked directly or indirectly from a buggy method using graph traversal…

Medium
3315

Construct the Minimum Bitwise Array II

Learn to build the minimum array matching a bitwise OR pattern for each prime in nums, focusing on binary optimization.

Medium
3316

Find Maximum Removals From Source String

Determine the maximum number of characters you can remove from source while keeping pattern as a subsequence using array…

Medium
3319

K-th Largest Perfect Subtree Size in Binary Tree

Find the size of the kth largest perfect subtree in a binary tree using tree traversal and state tracking.

Medium
3324

Find the Sequence of Strings Appeared on the Screen

Simulate Alice typing a target string with a special keyboard that appends letters one by one. Solve using string simula…

Medium
3325

Count Substrings With K-Frequency Characters I

Calculate the total number of substrings where at least one character repeats k times using a sliding window efficiently…

Medium
3326

Minimum Division Operations to Make Array Non Decreasing

Determine the minimum number of division operations to make an array non-decreasing using a greedy and invariant-based s…

Medium
3331

Find Subtree Sizes After Changes

Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…

Medium
3332

Maximum Points Tourist Can Earn

Calculate the maximum points a tourist can earn by choosing optimal city moves over k days using state transition DP.

Medium
3334

Find the Maximum Factor Score of Array

Calculate the maximum factor score of an integer array by optionally removing one element using LCM and GCD computations…

Medium
3335

Total Characters in String After Transformations I

Calculate the total number of characters in a string after repeated transformations using dynamic programming and freque…

Medium
3341

Find Minimum Time to Reach Last Room I

Find Minimum Time to Reach Last Room I challenges you to determine the minimum time to travel in a dungeon with a grid l…

Medium
3342

Find Minimum Time to Reach Last Room II

Calculate the minimum time to reach the last room in a grid with alternating move times using array and graph patterns.

Medium
3346

Maximum Frequency of an Element After Performing Operations I

Maximize the frequency of an element in an array after performing a series of operations to find the best possible resul…

Medium
3350

Adjacent Increasing Subarrays Detection II

Find the largest k where two adjacent strictly increasing subarrays of length k exist using binary search techniques.

Medium
3355

Zero Array Transformation I

Transform the given integer array into a zero array using range operations, focusing on prefix sum optimization and care…

Medium
3356

Zero Array Transformation II

Zero Array Transformation II requires determining the minimum query sequence to convert all array elements to zero using…

Medium
3361

Shift Distance Between Two Strings

Find the minimum cost of transforming one string into another, considering operations between characters.

Medium
3362

Zero Array Transformation III

Zero Array Transformation III requires removing the minimum number of queries to make all elements zero using greedy val…

Medium
3365

Rearrange K Substrings to Form Target String

Determine if s can be split into k equal substrings and rearranged to match t using a hash table for frequency tracking.

Medium
3366

Minimum Array Sum

Solve the Minimum Array Sum problem using dynamic programming by tracking states and operations to minimize the sum of a…

Medium
3371

Identify the Largest Outlier in an Array

Identify the largest outlier in an integer array using scanning and hash lookup for efficient detection and validation.

Medium
3372

Maximize the Number of Target Nodes After Connecting Trees I

Maximize the number of target nodes after connecting two trees using binary tree traversal and state tracking.

Medium
3376

Minimum Time to Break Locks I

Solve the Minimum Time to Break Locks I problem using state transition dynamic programming to minimize the time to break…

Medium
3377

Digit Operations to Make Two Integers Equal

Transform n into m using allowed digit operations without creating primes, applying math and graph strategies efficientl…

Medium
3380

Maximum Area Rectangle With Point Constraints I

Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.

Medium
3381

Maximum Subarray Sum With Length Divisible by K

Find the maximum sum of a subarray where the length of the subarray is divisible by k.

Medium
3387

Maximize Amount After Two Days of Conversions

Compute the maximum currency amount after two days using graph traversal and depth-first search for optimal conversions.

Medium
3388

Count Beautiful Splits in an Array

Learn to count all valid beautiful splits in an array using state transition dynamic programming efficiently and accurat…

Medium
3393

Count Paths With the Given XOR Value

Count the number of paths in a grid where the XOR of all values along the path equals a given number.

Medium
3394

Check if Grid can be Cut into Sections

Determine if an n x n grid can be divided with two horizontal or vertical cuts using rectangle ranges efficiently.

Medium
3397

Maximum Number of Distinct Elements After Operations

Maximize distinct elements in an array by performing at most one operation on each element.

Medium
3403

Find the Lexicographically Largest String From the Box I

This problem involves finding the lexicographically largest string from a given word using a two-pointer approach.

Medium
3404

Count Special Subsequences

Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…

Medium
3408

Design Task Manager

Design a Task Manager that can efficiently handle task management operations such as adding, editing, executing, and rem…

Medium
3409

Longest Subsequence With Decreasing Adjacent Difference

Find the length of the longest subsequence with non-increasing absolute adjacent differences.

Medium
3412

Find Mirror Score of a String

Calculate the mirror score of a string using stack-based state management for matching letters efficiently and accuratel…

Medium
3413

Maximum Coins From K Consecutive Bags

Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…

Medium
3418

Maximum Amount of Money Robot Can Earn

Find the maximum amount of money a robot can collect while neutralizing robbers on its path in a grid.

Medium
3419

Minimize the Maximum Edge Weight of Graph

Minimize the maximum edge weight in a graph after removing certain edges while ensuring node reachability.

Medium
3424

Minimum Cost to Make Arrays Identical

Minimize cost to make arrays identical by performing operations with given constraints and a greedy strategy.

Medium
3428

Maximum and Minimum Sums of at Most Size K Subsequences

Find the sum of the maximum and minimum elements of subsequences with at most k elements, using dynamic programming.

Medium
3429

Paint House IV

Solve the Paint House IV problem using state transition dynamic programming to minimize the painting costs while adherin…

Medium
3433

Count Mentions Per User

Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…

Medium
3434

Maximum Frequency After Subarray Operation

Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…

Medium
3439

Reschedule Meetings for Maximum Free Time I

Maximize free time by rescheduling up to k non-overlapping meetings within a fixed event using sliding window updates.

Medium
3440

Reschedule Meetings for Maximum Free Time II

Maximize free time by rescheduling at most one meeting using a greedy choice with invariant validation approach for arra…

Medium
3443

Maximum Manhattan Distance After K Changes

Solve Maximum Manhattan Distance After K Changes by scanning prefixes and testing the four diagonal target pairs with li…

Medium
3446

Sort Matrix by Diagonals

Sort Matrix by Diagonals groups cells by diagonal, then sorts bottom-left diagonals descending and top-right diagonals a…

Medium
3447

Assign Elements to Groups with Constraints

Assign elements to groups by size constraints with a sieve-like approach to find suitable element matches efficiently.

Medium
3453

Separate Squares I

Find the minimum y-coordinate of a horizontal line that balances the areas of squares above and below it.

Medium
3457

Eat Pizzas!

Maximize the total weight gained by optimally eating pizzas in groups of four using greedy selection and invariant valid…

Medium
3458

Select K Disjoint Special Substrings

Determine if k non-overlapping special substrings exist in a string using dynamic programming and careful substring trac…

Medium
3462

Maximum Sum With at Most K Elements

Find the maximum sum by selecting at most k elements from a 2D matrix respecting per-row limits using a greedy strategy.

Medium
3468

Find the Number of Copy Arrays

Find the number of possible arrays by leveraging bounds and math in this array-based problem.

Medium
3469

Find Minimum Cost to Remove Array Elements

Find the minimum cost to remove all elements from the array with dynamic programming.

Medium
3472

Longest Palindromic Subsequence After at Most K Operations

Find the longest palindromic subsequence of a string after performing at most k operations to adjust letters.

Medium
3473

Sum of K Subarrays With Length at Least M

Maximize the sum of k non-overlapping subarrays of at least length m using dynamic programming and prefix sums efficient…

Medium
3478

Choose K Elements With Maximum Sum

Choose K Elements With Maximum Sum involves sorting and selecting elements based on a specific rule, applying array plus…

Medium
3479

Fruits Into Baskets III

Fruits Into Baskets III requires placing fruits into baskets efficiently using binary search over the answer space for c…

Medium
3484

Design Spreadsheet

Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…

Medium
3488

Closest Equal Element Queries

Find the nearest index with the same value for each query using array scanning combined with hash lookups efficiently.

Medium
3493

Properties Graph

Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…

Medium
3494

Find the Minimum Amount of Time to Brew Potions

This problem involves calculating the minimum time required for wizards to brew potions based on their skills and mana u…

Medium
3499

Maximize Active Section with Trade I

Maximize the number of active sections in a binary string by performing at most one trade operation.

Medium
3503

Longest Palindrome After Substring Concatenation I

Compute the maximum palindrome length by concatenating substrings from two strings using state transition dynamic progra…

Medium
3508

Implement Router

Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.

Medium
3513

Number of Unique XOR Triplets I

Calculate all unique XOR triplet values in a permutation array using array traversal and bit manipulation techniques eff…

Medium
3514

Number of Unique XOR Triplets II

Count all unique XOR results from triplets in an integer array using array traversal and bit manipulation techniques eff…

Medium
3517

Smallest Palindromic Rearrangement I

Build the smallest palindrome by sorting the left half counts and mirroring them around the optional middle character.

Medium
3522

Calculate Score After Performing Instructions

Simulate a series of add and jump instructions on arrays to compute the final score efficiently using array scanning and…

Medium
3523

Make Array Non-decreasing

Determine the maximum size of a non-decreasing array by replacing subarrays with their maximum values efficiently.

Medium
3524

Find X Value of Array I

Determine the x-value of an array using state transition dynamic programming to count valid prefix-suffix operations eff…

Medium
3527

Find the Most Common Response

Find the most common survey response after eliminating duplicates within each day, using array scanning and hash lookups…

Medium
3528

Unit Conversion I

Solve the unit conversion problem by using graph traversal to compute equivalent unit amounts.

Medium
3529

Count Cells in Overlapping Horizontal and Vertical Substrings

Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…

Medium
3531

Count Covered Buildings

Determine how many buildings in an n x n city are completely surrounded using array scanning and hash lookup efficiently…

Medium
3532

Path Existence Queries in a Graph I

Determine if paths exist between nodes using array scanning and hash lookups for efficient component checks in graphs.

Medium
3537

Fill a Special Grid

Fill a Special Grid uses recursive divide-and-conquer to populate a 2^n x 2^n matrix with sequential integers uniquely i…

Medium
3542

Minimum Operations to Convert All Elements to Zero

Calculate the fewest operations to turn all numbers in an array to zero using subarray minimum elimination strategy.

Medium
3543

Maximum Weighted K-Edge Path

Determine the maximum sum of edge weights for a k-edge path in a DAG using state transition dynamic programming efficien…

Medium
3546

Equal Sum Grid Partition I

Determine if an m x n matrix grid can be split into two non-empty sections with equal sums by making a single horizontal…

Medium
3551

Minimum Swaps to Sort by Digit Sum

Calculate the minimum swaps to sort an array by digit sum, ensuring correct order with tiebreaker values for efficiency.

Medium
3552

Grid Teleportation Traversal

Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.

Medium
3556

Sum of Largest Prime Substrings

Compute the sum of the three largest unique primes from all substrings using hash table plus math efficiently.

Medium
3557

Find Maximum Number of Non Intersecting Substrings

Determine the maximum number of non-overlapping substrings in a word, each at least four characters and matching start-e…

Medium
3558

Number of Ways to Assign Edge Weights I

Calculate the number of valid edge weight assignments in a tree using DFS and binary-tree traversal with careful state t…

Medium
3561

Resulting String After Adjacent Removals

This problem focuses on removing adjacent characters in a string using a stack-based approach until no more operations a…

Medium
3566

Partition Array into Two Equal Product Subsets

Determine if you can partition an array into two subsets with equal product using recursion and bit manipulation.

Medium
3567

Minimum Absolute Difference in Sliding Submatrix

Find the minimum absolute difference in each k x k submatrix within a given 2D grid using array and sorting techniques.

Medium
3568

Minimum Moves to Clean the Classroom

Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.

Medium
3572

Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values

Select three distinct x-values from arrays to maximize the sum of their corresponding y-values efficiently using hashing…

Medium
3573

Best Time to Buy and Sell Stock V

Maximize profit from stock trades with at most k transactions using state transition dynamic programming for precise dec…

Medium
3576

Transform Array to All Equal Elements

Transform Array to All Equal Elements requires careful greedy choices and validating invariants to achieve uniformity ef…

Medium
3577

Count the Number of Computer Unlocking Permutations

Calculate the total valid unlocking sequences for computers based on their complexity using array and combinatorics logi…

Medium
3578

Count Partitions With Max-Min Difference at Most K

Count the number of valid ways to partition an array into contiguous segments where max-min difference is at most k.

Medium
3583

Count Special Triplets

Count Special Triplets requires scanning an array while tracking counts of previous and next values efficiently with has…

Medium
3584

Maximum Product of First and Last Elements of a Subsequence

Maximize the product of the first and last elements of any subsequence of size m in an integer array.

Medium
3587

Minimum Adjacent Swaps to Alternate Parity

Compute the minimum adjacent swaps to make array elements alternate between even and odd using greedy and invariant chec…

Medium
3588

Find Maximum Area of a Triangle

Find the maximum area of a triangle from 2D coordinates with at least one side parallel to the x-axis or y-axis.

Medium
3589

Count Prime-Gap Balanced Subarrays

Count the number of prime-gap balanced subarrays in an integer array using sliding window techniques and running state u…

Medium
3592

Inverse Coin Change

Recover coin denominations from a numWays array using state transition dynamic programming to reconstruct valid sets eff…

Medium
3593

Minimum Increments to Equalize Leaf Paths

Find the minimum number of increments needed to equalize leaf path scores in a tree with different node costs.

Medium
3597

Partition String

Partition a string into unique segments using hash table and string manipulation.

Medium
3598

Longest Common Prefix Between Adjacent Strings After Removals

Given an array of strings, find the longest common prefix length between adjacent strings after removals at each index.

Medium
3599

Partition Array to Minimize XOR

Partition an integer array into k subarrays to minimize the maximum XOR using state transition dynamic programming effic…

Medium
3603

Minimum Cost Path with Alternating Directions II

This problem focuses on finding the minimum cost path with alternating directions in a grid using dynamic programming.

Medium
3604

Minimum Time to Reach Destination in Directed Graph

The problem involves finding the minimum time to reach the destination in a directed graph with time-dependent edges.

Medium
3607

Power Grid Maintenance

Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…

Medium
3608

Minimum Time for K Connected Components

Find the minimum time to remove edges such that a graph with n nodes has at least k connected components.

Medium
3612

Process String with Special Operations I

Simulate a series of operations on a string to transform it into the desired result using special characters.

Medium
3613

Minimize Maximum Component Cost

Minimize Maximum Component Cost leverages binary search over edge weights to optimize the cost of graph components after…

Medium
3618

Split Array by Prime Indices

Split Array by Prime Indices challenges you to separate elements at prime positions and minimize the absolute sum differ…

Medium
3619

Count Islands With Total Value Divisible by K

Count the number of islands in a grid where the sum of each island's values is divisible by a given integer k.

Medium
3623

Count Number of Trapezoids I

Given a list of distinct points, count the number of unique horizontal trapezoids that can be formed by selecting four p…

Medium
3626

Find Stores with Inventory Imbalance

Solve Find Stores with Inventory Imbalance by comparing cheapest and most expensive product stock within each store.

Medium
3627

Maximum Median Sum of Subsequences of Size 3

Maximize the sum of medians from subsequences of size 3 by choosing elements wisely from the array.

Medium
3628

Maximum Number of Subsequences After One Inserting

Maximize the number of "LCT" subsequences in a string after one insertion of an uppercase letter.

Medium
3629

Minimum Jumps to Reach End via Prime Teleportation

Solve the problem of finding the minimum jumps to reach the end of an array with prime teleportation steps.

Medium
3634

Minimum Removals to Balance Array

Determine the fewest elements to remove from nums so the remaining array satisfies the maximum-to-minimum ratio within k…

Medium
3635

Earliest Finish Time for Land and Water Rides II

Determine the minimum completion time for a tourist to ride one land and one water ride using optimal scheduling.

Medium
3638

Maximum Balanced Shipments

The Maximum Balanced Shipments problem requires forming the maximum number of balanced shipments from a given set of par…

Medium
3639

Minimum Time to Activate String

Find the minimum time to activate a string with a given order of replacements and a specific number of valid substrings.

Medium

Top Topics In This Track

route

Guided Practice Path

AI recommends problems by your level and tracks your progress.

Start Guided Patharrow_forward
Medium LeetCode Problems