array
array is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
Pattern Bridge
High-Pressure Round
Two Sum
Two Sum is solved fastest by storing seen values in a hash map and checking each number's needed complement once.
Median of Two Sorted Arrays
Find the median of two sorted arrays using binary search for efficient O(log(min(m, n))) time complexity.
Container With Most Water
Find two vertical lines that can form a container with the most water in a given array of heights.
Longest Common Prefix
Find the longest common prefix in an array of strings, returning an empty string if none exists.
3Sum
Given an integer array, return all unique triplets where the sum is zero using two-pointer scanning with careful duplica…
3Sum Closest
Find the sum of three integers in an array that is closest to a given target using two-pointer scanning.
4Sum
The 4Sum problem requires finding all unique quadruplets in an array that sum to a specific target value.
Remove Duplicates from Sorted Array
Learn how to remove duplicates from a sorted array in-place using two-pointer scanning while preserving element order.
Remove Element
Remove Element challenges you to remove a value from an array in-place using efficient two-pointer scanning and tracking…
Next Permutation
Next Permutation is a medium-difficulty problem focusing on generating the next lexicographically greater permutation of…
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.
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.
Search Insert Position
Find the correct index for a target value in a sorted array using binary search, or return the position where it should …
Valid Sudoku
Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …
Sudoku Solver
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
Combination Sum
Find all unique combinations of numbers from a distinct array that sum to a target using controlled backtracking search.
Combination Sum II
Find all unique combinations of numbers that sum to a target using backtracking with careful pruning to avoid duplicates…
First Missing Positive
Identify the smallest missing positive integer in an unsorted array using constant space and linear time scanning techni…
Trapping Rain Water
Calculate the total trapped rain water using the elevation map array, leveraging dynamic programming and two-pointer pat…
Jump Game II
Jump Game II requires finding the minimum jumps to reach the end of an array using dynamic programming and greedy techni…
Permutations
Generate all possible orderings of a distinct integer array using backtracking search with careful pruning to avoid dupl…
Permutations II
Generate all unique permutations of an array containing duplicates using backtracking and pruning to avoid repeated sequ…
Rotate Image
Rotate an n x n matrix 90 degrees clockwise in-place using array manipulation and mathematical indexing techniques effic…
Group Anagrams
Group the anagrams in a list of strings using efficient hash table-based methods, focusing on array scanning.
N-Queens
Solve the N-Queens problem using backtracking with pruning, exploring all valid board placements while avoiding conflict…
Maximum Subarray
Maximum Subarray is a classic state transition dynamic programming problem about deciding whether to extend or restart a…
Spiral Matrix
Given an m x n matrix, return all elements in spiral order starting from the top-left corner.
Jump Game
Solve the Jump Game problem using state transition dynamic programming to determine if you can reach the last index of t…
Merge Intervals
Merge Intervals requires sorting an array of interval pairs and combining overlaps efficiently using sequential comparis…
Insert Interval
Given a sorted array of non-overlapping intervals, insert a new interval and merge any overlapping intervals.
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…
Unique Paths II
Calculate the number of unique paths from top-left to bottom-right in a grid with obstacles using dynamic programming st…
Minimum Path Sum
Compute the minimum sum from top-left to bottom-right in a grid using state transition dynamic programming efficiently.
Plus One
Given a number as an array of digits, increment it by one and return the updated array of digits.
Text Justification
Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.
Set Matrix Zeroes
Modify the matrix in place by setting rows and columns to zero when an element is zero.
Search a 2D Matrix
Search a 2D matrix efficiently using binary search over its linearized index, ensuring correctness in row-major sorted a…
Sort Colors
Sort Colors requires in-place reordering of an array using a two-pointer scanning strategy to group 0s, 1s, and 2s effic…
Subsets
Generate all subsets of a set of unique integers using backtracking with pruning to avoid duplicates.
Word Search
Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.
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…
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…
Largest Rectangle in Histogram
Find the maximal rectangular area in a histogram using stack-based state management for precise bar tracking and width c…
Maximal Rectangle
Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…
Merge Sorted Array
Merge two sorted arrays into the first array in non-decreasing order, using a two-pointer approach.
Subsets II
Subsets II problem asks to generate unique subsets from an array with possible duplicates using backtracking search with…
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.
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…
Convert Sorted Array to Binary Search Tree
Pick the middle element as root at each step so the sorted array becomes a height-balanced BST with valid ordering.
Pascal's Triangle
Generate the first numRows of Pascal's Triangle using dynamic programming with clear state transitions and array manipul…
Pascal's Triangle II
Compute the specific row of Pascal's Triangle using efficient state transition dynamic programming with array-based upda…
Triangle
Given a triangle, return the minimum path sum from top to bottom, moving to adjacent numbers in the row below.
Best Time to Buy and Sell Stock
Maximize stock profit by identifying the optimal buy and sell days using dynamic programming.
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…
Best Time to Buy and Sell Stock III
Determine the maximum profit from at most two stock transactions using state transition dynamic programming on price arr…
Longest Consecutive Sequence
Find the length of the longest consecutive elements sequence in an unsorted array using array scanning and hash lookup.
Surrounded Regions
Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.
Gas Station
The Gas Station problem requires finding the starting station index for a full circular trip with gas stations and costs…
Candy
The Candy problem is a greedy algorithm challenge where you need to minimize candy distribution while satisfying certain…
Single Number
Solve the Single Number problem using an efficient approach with constant space and linear time complexity.
Single Number II
Find the single element in an array where every other element appears three times, using bit manipulation and constant s…
Word Break
Determine if a string can be fully segmented into dictionary words using array scanning and hash-based lookups for effic…
Word Break II
Given a string and dictionary, return all possible sentences by adding spaces where each word is in the dictionary.
Max Points on a Line
Find the maximum number of points on a straight line in a 2D plane using array scanning and hash lookup.
Evaluate Reverse Polish Notation
Compute the result of an arithmetic expression in Reverse Polish Notation using a stack to manage operands efficiently.
Maximum Product Subarray
Find the subarray with the largest product in an integer array using dynamic programming techniques.
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.
Find Minimum in Rotated Sorted Array II
Find the minimum in a rotated sorted array with possible duplicates using binary search.
Find Peak Element
Find Peak Element leverages binary search for efficiently locating a peak in an array, a problem commonly asked in techn…
Maximum Gap
Find the largest difference between successive elements in a sorted array efficiently using linear time techniques and b…
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.
Majority Element
Find the majority element in an array, where the element appears more than n/2 times, using efficient algorithms.
Dungeon Game
Calculate the minimum initial health the knight needs to survive the dungeon using state transition dynamic programming …
Largest Number
The problem asks to arrange integers to form the largest possible number, focusing on greedy algorithms and string handl…
Best Time to Buy and Sell Stock IV
Determine the maximum profit from at most k stock transactions using state transition dynamic programming on an array of…
Rotate Array
Rotate Array challenges you to shift elements right by k steps using precise two-pointer scanning and invariant tracking…
House Robber
Maximize the amount of money you can rob tonight without alerting the police by applying dynamic programming with state …
Number of Islands
Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…
Count Primes
Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.
Minimum Size Subarray Sum
Find the minimal length of a subarray whose sum is greater than or equal to the target using efficient algorithms.
Word Search II
Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.
House Robber II
Maximize your loot by robbing houses arranged in a circle without alerting the police using dynamic programming.
Kth Largest Element in an Array
Find the kth largest element in an unsorted array using optimal approaches like Quickselect or heaps.
Combination Sum III
Find all unique combinations of k numbers adding to n using efficient backtracking with pruning in arrays.
Contains Duplicate
Determine if an integer array contains any duplicate values by efficiently scanning with a hash lookup to ensure fast de…
The Skyline Problem
The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …
Contains Duplicate II
Check if any two equal numbers exist within k indices using array scanning and hash table lookup efficiently.
Contains Duplicate III
The problem involves finding a pair of indices in an array where the index and value differences are within given limits…
Maximal Square
Maximal Square is a matrix-based dynamic programming problem that focuses on finding the largest square filled with 1's.
Summary Ranges
Summary Ranges involves converting a sorted array of unique integers into a minimal list of range strings.
Majority Element II
Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…
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…
Sliding Window Maximum
Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…
Search a 2D Matrix II
Efficiently search for a target in a 2D matrix using binary search and matrix properties.
Single Number III
Find the two unique numbers in an array where all other numbers appear exactly twice using bit manipulation efficiently.
Missing Number
Find the missing number in an array containing distinct numbers in the range [0, n].
H-Index
Determine a researcher's h-index by analyzing citations using array sorting and counting techniques efficiently and accu…
H-Index II
Compute a researcher's H-Index from a sorted citation array using binary search over the valid answer space efficiently.
Move Zeroes
Move all zeros in an array to the end while preserving the order of non-zero elements using efficient in-place operation…
Peeking Iterator
Design an iterator with peek functionality, adding to the standard next and hasNext operations for efficient element acc…
Find the Duplicate Number
The problem involves finding the duplicate number in an array of integers, using a binary search approach over the valid…
Game of Life
Solve the Game of Life by updating each cell based on its eight neighbors using Array and Matrix simulation patterns eff…
Longest Increasing Subsequence
Solve the Longest Increasing Subsequence problem using dynamic programming and binary search to efficiently find the sub…
Range Sum Query - Immutable
The Range Sum Query - Immutable problem involves implementing a data structure to handle range sum queries efficiently.
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.
Range Sum Query - Mutable
Implement a mutable range sum query using efficient design patterns to handle multiple updates and range sum queries.
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…
Burst Balloons
Burst Balloons is a hard dynamic programming problem requiring careful state transitions to maximize coins collected eff…
Super Ugly Number
Compute the nth super ugly number efficiently using dynamic programming with state transitions based on the given prime …
Count of Smaller Numbers After Self
Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.
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…
Create Maximum Number
Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.
Coin Change
Find the minimum number of coins needed to reach a target amount using dynamic programming state transitions efficiently…
Wiggle Sort II
Rearrange an array in a way that every odd-indexed element is greater than its adjacent even-indexed elements.
Count of Range Sum
Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…
Longest Increasing Path in a Matrix
Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.
Patching Array
Patching Array requires adding the minimum numbers to cover all sums from 1 to n using greedy choices and invariant chec…
Increasing Triplet Subsequence
Identify if an array contains a strictly increasing triplet by maintaining a running minimal and middle value efficientl…
Self Crossing
Determine if a path defined by sequential distances on a 2D plane crosses itself using array and math reasoning.
Palindrome Pairs
Find all pairs of words in a list that form palindromes when concatenated using efficient scanning and hash mapping.
Top K Frequent Elements
Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.
Intersection of Two Arrays
Find the intersection of two arrays while ensuring unique elements using efficient array scanning and hash lookups.
Intersection of Two Arrays II
Find the intersection of two arrays, accounting for multiple occurrences of the same number.
Russian Doll Envelopes
Russian Doll Envelopes is a dynamic programming problem that involves finding the longest chain of envelopes that can be…
Max Sum of Rectangle No Larger Than K
Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…
Largest Divisible Subset
Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…
Find K Pairs with Smallest Sums
Find K Pairs with Smallest Sums combines arrays and heap usage to select the smallest sum pairs efficiently.
Wiggle Subsequence
Find the longest wiggle subsequence in an integer array using state transition dynamic programming with greedy optimizat…
Combination Sum IV
Combination Sum IV asks to find the number of combinations that sum to a given target using elements from an array.
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…
Insert Delete GetRandom O(1)
Implement a data structure supporting insert, delete, and getRandom in average O(1) using array plus hash mapping.
Insert Delete GetRandom O(1) - Duplicates allowed
This problem challenges you to design a data structure that supports insertion, removal, and random access with O(1) tim…
Shuffle an Array
Shuffle an Array requires designing a class to randomly permute an integer array while ensuring all permutations are equ…
Perfect Rectangle
Determine if given axis-aligned rectangles form a perfect cover using array scanning and hash-based corner counting tech…
UTF-8 Validation
Determine if an integer array represents valid UTF-8 encoding based on its byte sequences using bit manipulation.
Rotate Function
Maximize the rotation function by rotating the array and calculating the weighted sum for all rotations.
Evaluate Division
Compute the results of division queries from given equations using graph traversal and depth-first search efficiently.
Frog Jump
Determine if a frog can cross a river using jumps constrained by previous step sizes in a dynamic programming state tran…
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…
Trapping Rain Water II
Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.
Split Array Largest Sum
Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…
Arithmetic Slices
Count the number of arithmetic subarrays in a given integer array using dynamic programming.
Third Maximum Number
Find the third distinct maximum number in an array using array traversal and sorting techniques, handling duplicates car…
Partition Equal Subset Sum
Determine if an array can be partitioned into two subsets with equal sum using dynamic programming techniques.
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.
Battleships in a Board
Count the number of non-overlapping battleships on a 2D board using array traversal and depth-first search patterns effi…
Maximum XOR of Two Numbers in an Array
Find the maximum XOR of two numbers in an integer array using efficient bit manipulation techniques.
Construct Quad Tree
Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.
Non-overlapping Intervals
Determine the minimum number of intervals to remove from a list to ensure no intervals overlap using dynamic programming…
Find All Duplicates in an Array
Find all integers that appear twice in an array with O(n) time and constant space complexity.
Arithmetic Slices II - Subsequence
Count all arithmetic subsequences in an array using dynamic programming with precise state transitions for correctness.
Number of Boomerangs
Compute all valid boomerang tuples in a point set using array scanning with hash maps to track distances efficiently.
Find All Numbers Disappeared in an Array
Identify all missing numbers in an array using efficient scanning and hash-based lookup for optimal performance.
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.
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.
4Sum II
Count all quadruples from four integer arrays that sum to zero using efficient array scanning and hash table lookups.
Assign Cookies
Maximize content children by assigning at most one cookie per child using two-pointer scanning and greedy sorting techni…
132 Pattern
Identify whether a given integer array contains a 132 pattern subsequence using efficient stack and search techniques.
Circular Array Loop
Detect whether a circular array contains a loop of consistent direction using efficient array scanning and hash lookup t…
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.
Island Perimeter
Determine the perimeter of an island in a grid of land and water cells using DFS or BFS.
Concatenated Words
Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …
Matchsticks to Square
The problem asks to determine if we can use matchsticks to form a square, exploring dynamic programming and backtracking…
Ones and Zeroes
Solve the Ones and Zeroes problem using dynamic programming with state transition, focusing on array and string manipula…
Heaters
Determine the minimum heater radius to cover all houses using a binary search over potential radius values efficiently.
Total Hamming Distance
Calculate the total Hamming distance between all pairs in an integer array using efficient bit manipulation techniques.
Sliding Window Median
Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…
Max Consecutive Ones
Find the maximum sequence of consecutive 1s in a binary array using an efficient array-driven scanning approach.
Predict the Winner
Predict the Winner involves two players taking turns to maximize their score by picking from either end of an array, opt…
Non-decreasing Subsequences
Return all possible non-decreasing subsequences with at least two elements from the input array, nums.
Reverse Pairs
Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.
Target Sum
Target Sum requires counting all expressions from nums using '+' or '-' that evaluate exactly to the given target intege…
Teemo Attacking
Compute the total poisoned time Ashe experiences from Teemo's attacks using an array-based simulation approach efficient…
Next Greater Element I
Find the next greater element for each number in nums1 from the nums2 array using an optimized approach.
Random Point in Non-overlapping Rectangles
Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.
Diagonal Traverse
Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.
Keyboard Row
Identify all words from a list that can be typed using letters from only one row of a standard American keyboard.
IPO
Maximize total capital by selecting up to k projects, based on initial capital and project profits using a greedy strate…
Next Greater Element II
Solve the Next Greater Element II problem by using a stack-based state management approach for circular arrays.
Relative Ranks
Solve Relative Ranks by sorting scores with original indices, then writing medal labels or numeric places back in answer…
Super Washing Machines
Calculate the minimum moves to balance dresses across washing machines using a greedy strategy and invariant validation …
Coin Change II
Calculate the number of unique coin combinations to reach a target amount using state transition dynamic programming eff…
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 …
Continuous Subarray Sum
Identify if any continuous subarray sums to a multiple of k using prefix sums and hash table tracking efficiently.
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…
Contiguous Array
Find the maximum length contiguous subarray with equal numbers of 0s and 1s using array scanning and hash lookup efficie…
Beautiful Arrangement
The Beautiful Arrangement problem asks for the number of valid permutations of n integers satisfying specific divisibili…
Random Pick with Weight
Random Pick with Weight requires implementing a probabilistic index picker using prefix sums and binary search efficient…
Minesweeper
Solve the Minesweeper game by updating revealed squares and handling clicks with Depth-First Search and Array manipulati…
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.
Minimum Time Difference
Calculate the smallest time difference between clock points using array manipulation and mathematical conversions effici…
Single Element in a Sorted Array
Find the single non-duplicate element in a sorted array where every other element appears exactly twice.
01 Matrix
The '01 Matrix' problem challenges you to find the nearest zero for each cell in a binary matrix using dynamic programmi…
Remove Boxes
Maximize points by strategically removing contiguous same-colored boxes using state transition dynamic programming and m…
Optimal Division
Maximize the value of an expression by optimally placing parentheses for division operations.
Brick Wall
Solve the Brick Wall problem using array scanning and hash lookups to minimize crossed bricks from a vertical line.
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 …
Array Partition
Maximize the sum of minimums of n pairs in a 2n integer array using a greedy pairing strategy efficiently.
Array Nesting
Find the longest nested set in a permutation array using a depth-first traversal, handling cycles efficiently for medium…
Reshape the Matrix
Reshape the Matrix involves transforming a 2D matrix into a new matrix with the same elements in row-major order, follow…
Distribute Candies
Maximize the number of different candies Alice can eat given a set of candies and constraints on quantity.
Shortest Unsorted Continuous Subarray
Find the shortest unsorted continuous subarray that, if sorted, would sort the entire array.
Erect the Fence
Find the perimeter fence of a garden by determining the outermost trees in a set of given tree coordinates.
Longest Harmonious Subsequence
Find the length of the longest harmonious subsequence in an integer array using array scanning and hash-based frequency …
Range Addition II
Range Addition II requires counting maximum values in a matrix after incremental operations using array and math reasoni…
Minimum Index Sum of Two Lists
Find the common strings between two lists with the smallest index sum in this easy problem involving array scanning and …
Can Place Flowers
Determine if n new flowers can be planted in a flowerbed, ensuring no adjacent flowers using a greedy approach.
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…
Valid Triangle Number
Count all triplets in an integer array that satisfy the triangle inequality to form valid triangles efficiently using so…
Task Scheduler
Task Scheduler is solved by counting task frequencies and computing how cooldown gaps force idle slots around the most f…
Design Circular Queue
Design a circular queue that allows efficient FIFO operations using linked-list pointer manipulation to optimize space u…
Maximum Distance in Arrays
Maximum Distance in Arrays uses a greedy running minimum and maximum from previous arrays to validate cross array distan…
Maximum Product of Three Numbers
Find three numbers in an array whose product is the largest using sorting and careful handling of negative values.
Course Schedule III
Solve the 'Course Schedule III' problem with a greedy approach involving course selection and validation of constraints.
Smallest Range Covering Elements from K Lists
Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…
Exclusive Time of Functions
Solve the 'Exclusive Time of Functions' problem using stack-based state management for accurate function execution time …
Shopping Offers
Minimize the cost of purchasing items using available special offers with state transition dynamic programming.
Design Circular Deque
Design and implement a circular deque using linked-list pointer manipulation, ensuring efficient insertion and deletion …
Maximum Average Subarray I
Find the maximum average of any contiguous subarray of length k in a given integer array using a sliding window approach…
Set Mismatch
Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…
Maximum Length of Pair Chain
Determine the maximum length of a chain formed by pairs using dynamic programming and greedy sorting techniques efficien…
Replace Words
Replace words in a sentence using the shortest root from a dictionary, applying efficient array scanning and hash lookup…
Maximum Binary Tree
Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …
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…
Split Array into Consecutive Subsequences
Verify if it's possible to split a sorted array into consecutive subsequences of length 3 or more.
Image Smoother
Apply a 3x3 smoothing filter to a matrix, rounding down each cell average including surrounding neighbors for accurate r…
Non-decreasing Array
Check if an array can become non-decreasing by modifying at most one element using an array-driven solution strategy.
Beautiful Arrangement II
Construct a beautiful arrangement of integers from 1 to n with k distinct integers, optimizing for time and space effici…
Number of Longest Increasing Subsequence
This problem challenges you to find the number of longest increasing subsequences in a given array of integers.
Longest Continuous Increasing Subsequence
Find the length of the longest continuous increasing subsequence in an unsorted integer array using an array-driven solu…
Cut Off Trees for Golf Event
Determine the minimum steps to cut all trees in a forest matrix in ascending height order using BFS traversal and priori…
24 Game
Solve the 24 Game by arranging four card numbers using arithmetic operators and parentheses to reach exactly 24 efficien…
Baseball Game
Simulate baseball score operations using a stack-based approach to compute the final score after all operations.
Maximum Sum of 3 Non-Overlapping Subarrays
Maximize the sum of three non-overlapping subarrays with length k in an integer array using dynamic programming.
Employee Importance
Calculate an employee's total importance including all direct and indirect subordinates using array scanning and hash lo…
Stickers to Spell Word
Determine the minimum number of stickers needed to spell a target word using array scanning and hash lookups for efficie…
Top K Frequent Words
Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…
Max Area of Island
Find the largest connected land area in a binary grid using array traversal and depth-first search efficiently.
Degree of an Array
Find the shortest subarray with the same degree as the given array using efficient array scanning and hash lookups.
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…
Falling Squares
Solve Falling Squares by efficiently computing maximum stack heights using arrays with segment tree optimization techniq…
Binary Search
Solve the Binary Search problem by finding the index of a target value in a sorted array with O(log n) complexity.
Design HashSet
Implement a custom HashSet without built-in libraries using array scanning and hash lookup for efficient membership chec…
Design HashMap
Implement a custom HashMap from scratch using array scanning and hash lookup without built-in libraries for efficient ke…
Random Pick with Blacklist
Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…
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…
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…
1-bit and 2-bit Characters
Determine whether the last character in a binary array represents a one-bit character or a two-bit character.
Maximum Length of Repeated Subarray
Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.
Find K-th Smallest Pair Distance
Solve Find K-th Smallest Pair Distance by sorting nums, then binary searching the distance and counting valid pairs with…
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.
Accounts Merge
Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…
Remove Comments
Remove comments from a given C++ program source array, handling line and block comments.
Find Pivot Index
Find the pivot index in an array where the sums of elements on both sides are equal using array and prefix sum technique…
My Calendar I
Implement a calendar supporting non-overlapping event bookings using binary search for efficient insertion and conflict …
My Calendar II
Implement a calendar that allows double bookings but prevents triple bookings, managing overlapping intervals efficientl…
Flood Fill
Flood Fill is an array and DFS problem where you change connected pixels to a target color efficiently using recursion o…
Asteroid Collision
Determine the final positions of moving asteroids using a stack-based simulation for efficient collision resolution in l…
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…
Delete and Earn
Maximize points by deleting numbers from an array while removing all adjacent values, using dynamic programming efficien…
Cherry Pickup
Maximize cherries collected on a grid, employing state transition dynamic programming with careful navigation across obs…
Find Smallest Letter Greater Than Target
Locate the smallest character in a sorted array that is strictly greater than a given target using efficient binary sear…
Prefix and Suffix Search
Design a dictionary to search words by both prefix and suffix using a Trie structure and hash lookups.
Min Cost Climbing Stairs
Compute the minimum cost to reach the top of a staircase using dynamic programming and step-by-step state transitions ef…
Largest Number At Least Twice of Others
Determine if the largest number in the array is at least twice as large as every other element, and return its index or …
Shortest Completing Word
Find the shortest word that completes the license plate by matching all required letters, considering frequency and case…
Contain Virus
Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…
Open the Lock
Solve the Open the Lock problem using array scanning plus hash lookup to efficiently find the shortest unlock sequence.
Set Intersection Size At Least Two
Solve the Set Intersection Size At Least Two problem using a greedy approach and invariant validation.
Largest Plus Sign
Find the largest axis-aligned plus sign in a binary grid with some mines using dynamic programming.
Toeplitz Matrix
Determine if a given matrix is a Toeplitz matrix by checking diagonal consistency.
Max Chunks To Make Sorted II
Determine the maximum number of chunks you can split an array into so that sorting each chunk results in a fully sorted …
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…
Sliding Puzzle
Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …
Global and Local Inversions
Determine if every global inversion in a permutation array is also a local inversion using array and math logic efficien…
Swim in Rising Water
Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.
Rabbits in Forest
Solve Rabbits in Forest by grouping equal answers and rounding each group into the smallest valid color-class size.
Transform to Chessboard
Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.
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.
Escape The Ghosts
Escape The Ghosts tests your ability to analyze movements in an infinite grid while racing against ghost positions using…
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…
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.
Number of Subarrays with Bounded Maximum
Count the number of contiguous subarrays with a bounded maximum value using a two-pointer approach.
Smallest Rotation with Highest Score
Find the smallest rotation index with the highest score using array and prefix sum techniques.
Minimum Swaps To Make Sequences Increasing
This problem involves finding the minimum number of swaps needed to make two sequences strictly increasing using dynamic…
Bricks Falling When Hit
Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.
Unique Morse Code Words
Determine how many unique Morse code transformations can be generated from a list of words using a hash table and array …
Split Array With Same Average
Determine whether an integer array can be partitioned into two non-empty subarrays with the same average using dynamic p…
Number of Lines To Write String
Calculate how many lines are needed to write a string given individual letter widths, constrained to 100 pixels per line…
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…
Expressive Words
Expressive Words challenges you to determine if a word can be transformed into a given string by extending groups of rep…
Chalkboard XOR Game
The Chalkboard XOR Game is a game theory problem involving array manipulation and bitwise XOR, where players alternate e…
Subdomain Visit Count
The Subdomain Visit Count problem requires counting the visits to all subdomains of a given domain from a list of count-…
Largest Triangle Area
Find the area of the largest triangle formed by three distinct points on a 2D plane.
Largest Sum of Averages
Maximize the sum of averages by partitioning an integer array into at most k contiguous subarrays using dynamic programm…
Bus Routes
Bus Routes is solved by BFS over buses and stops, using stop-to-route hashing to avoid expensive repeated route scans.
Linked List Components
Count the number of connected components in a linked list subset using array scanning and hash table lookups efficiently…
Most Common Word
Find the most frequent non-banned word in a paragraph, excluding punctuation, using an efficient array scan and hash tab…
Short Encoding of Words
Find the minimum length of a reference string encoding an array of words using array scanning and hash lookup efficientl…
Shortest Distance to a Character
Compute the minimum distance from each character in a string to a target character using efficient scanning techniques.
Card Flipping Game
The Card Flipping Game problem asks for the smallest integer that can be facing down but not up after flipping cards.
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…
Friends Of Appropriate Ages
The Friends Of Appropriate Ages problem involves counting valid friend requests between people based on their ages with …
Most Profit Assigning Work
Assign workers to jobs maximizing total profit using difficulty, profit, and worker arrays efficiently with binary searc…
Making A Large Island
Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…
Flipping an Image
Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.
Find And Replace in String
This problem challenges you to perform multiple string replacements at specific indices using a pattern involving array …
Image Overlap
Image Overlap requires calculating the overlap between two binary matrices by translating one image over the other.
Similar String Groups
Determine the number of connected groups of similar strings by swapping at most two letters using array scanning and has…
Magic Squares In Grid
Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.
Guess the Word
Master the Guess the Word problem by applying array manipulation, match-counting math, and strategic interactive guessin…
Longest Mountain in Array
Find the length of the longest subarray forming a mountain pattern using state transitions and two-pointer logic efficie…
Hand of Straights
Check if a hand of cards can be rearranged into groups of consecutive values.
Shifting Letters
Given a string and a shift array, shift the first i+1 letters of the string as specified in the array.
Maximize Distance to Closest Person
Determine the seat placement that maximizes distance to the nearest person using a linear array scan strategy efficientl…
Rectangle Area II
The problem involves calculating the total area covered by multiple rectangles, ensuring overlap is counted only once.
Loud and Rich
Determine the quietest person richer than each individual using graph indegree analysis and topological ordering techniq…
Peak Index in a Mountain Array
Find the peak index in a mountain array using binary search for efficient O(log n) time complexity.
Car Fleet
The Car Fleet problem asks how many car fleets will reach a target given their starting positions and speeds, considerin…
Minimum Cost to Hire K Workers
Find the minimum cost to hire exactly k workers based on quality and wage expectations in this challenging greedy proble…
Lemonade Change
Determine if you can provide exact change to every customer at a lemonade stand using greedy bill management techniques.
Score After Flipping Matrix
Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.
Shortest Subarray with Sum at Least K
Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.
Shortest Path to Get All Keys
Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.
Transpose Matrix
Transpose Matrix problem requires flipping a matrix's rows and columns to return the transposed version.
Advantage Shuffle
Maximize the advantage of nums1 over nums2 using a two-pointer greedy strategy, carefully tracking which elements beat o…
Minimum Number of Refueling Stops
Determine the minimum number of refueling stops needed to reach a target using dynamic programming and greedy strategies…
Length of Longest Fibonacci Subsequence
Find the length of the longest Fibonacci-like subsequence from a strictly increasing array of integers.
Walking Robot Simulation
The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…
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…
Stone Game
Stone Game is a dynamic programming problem where players alternate taking stones from piles to maximize their score.
Profitable Schemes
Given a group of members and a list of crimes, count the profitable schemes that meet the profit and group constraints.
Boats to Save People
Find the minimum number of boats required to save all people, using a two-pointer approach for efficient pairing.
Projection Area of 3D Shapes
Calculate the projection area of a 3D shape defined by a grid of towers with varying heights.
Spiral Matrix III
Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…
Fair Candy Swap
Determine which single candy box Alice and Bob should swap to equalize their total candies using array scanning and hash…
Construct Binary Tree from Preorder and Postorder Traversal
Reconstruct a binary tree from preorder and postorder traversals using array scanning and hash lookup.
Find and Replace Pattern
Identify all words matching a given pattern by checking consistent letter mappings using hash tables and array scanning …
Sum of Subsequence Widths
Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.
Surface Area of 3D Shapes
Solve the Surface Area of 3D Shapes problem using array manipulation and mathematical formulas to calculate surface area…
Groups of Special-Equivalent Strings
Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.
Monotonic Array
Determine if an integer array is entirely monotone increasing or decreasing using a clear array-driven approach.
Bitwise ORs of Subarrays
Compute the number of unique bitwise OR values from all non-empty subarrays using dynamic state transitions efficiently.
RLE Iterator
Design an efficient iterator for a run-length encoded array, handling large counts and sequential access correctly every…
Numbers At Most N Given Digit Set
The 'Numbers At Most N Given Digit Set' problem requires calculating how many numbers can be formed using a given digit …
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…
Sort Array By Parity
Reorder an integer array so all even numbers come before odd numbers using a precise two-pointer scanning method.
Sum of Subarray Minimums
Calculate the sum of minimum values across all subarrays of a given array modulo 10^9 + 7.
Smallest Range I
Find the smallest score of an array after applying an operation to each element within a given range.
Snakes and Ladders
Solve the Snakes and Ladders problem using a BFS strategy to efficiently navigate the board and reach the final square.
Smallest Range II
Determine the minimum possible difference between the largest and smallest numbers after adjusting each by plus or minus…
Online Election
Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…
Sort an Array
Sort an array using an optimal algorithm, focusing on time and space complexity considerations.
X of a Kind in a Deck of Cards
Solve the problem of determining if a deck can be partitioned into groups with equal occurrences of card values.
Partition Array into Disjoint Intervals
Partition the array into two subarrays such that the left contains the smallest possible elements and the right contains…
Word Subsets
Word Subsets is solved by merging words2 into one max-frequency requirement, then scanning words1 against that fixed let…
Maximum Sum Circular Subarray
Find the maximum sum of a circular subarray using state transition dynamic programming, optimizing for wraparound cases …
Sort Array By Parity II
Sort an array where even numbers appear at even indices and odd numbers appear at odd indices using two-pointer scanning…
3Sum With Multiplicity
Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…
Minimize Malware Spread
Identify which single infected node to remove to minimize total malware spread in a connected network graph efficiently.
Three Equal Parts
Divide a binary array into three contiguous parts such that each part represents the same integer value in binary, using…
Minimize Malware Spread II
Minimize Malware Spread II asks to minimize the spread of malware in a network of nodes by removing one infected node.
Unique Email Addresses
Identify the count of unique email addresses by normalizing local names and using hash-based lookups efficiently.
Binary Subarrays With Sum
Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…
Minimum Falling Path Sum
Minimum Falling Path Sum is a matrix dynamic programming problem where each cell depends on three reachable cells above …
Beautiful Array
Beautiful Array builds a valid permutation by recursively separating odd and even positions so no middle-average triple …
Shortest Bridge
Find the minimum flips to connect two separate islands in a binary matrix using Array and DFS techniques efficiently.
Reorder Data in Log Files
Reorder Data in Log Files requires sorting letter-logs lexicographically while keeping digit-logs in original order for …
Minimum Area Rectangle
Find the minimum area of a rectangle formed by given points on a 2D plane with sides parallel to axes.
Valid Mountain Array
The 'Valid Mountain Array' problem requires determining if an array meets the conditions of a valid mountain array using…
DI String Match
Reconstruct a permutation from a DI string using two-pointer scanning, carefully tracking the increasing and decreasing …
Find the Shortest Superstring
This problem requires constructing the shortest string containing all input words using state transition dynamic program…
Delete Columns to Make Sorted
The 'Delete Columns to Make Sorted' problem asks to remove unsorted columns from a string array, ensuring all columns ar…
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.
Validate Stack Sequences
Determine if a sequence of push and pop operations can produce the given popped array using a stack-based state approach…
Bag of Tokens
Maximize your score in the Bag of Tokens problem by strategically playing tokens with two-pointer scanning and greedy te…
Largest Time for Given Digits
Given four digits, determine the latest valid 24-hour time possible using each digit exactly once with backtracking.
Reveal Cards In Increasing Order
Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.
Largest Component Size by Common Factor
Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …
Verifying an Alien Dictionary
Verify if a sequence of words is sorted according to an alien language's custom alphabet order using array scanning and …
Array of Doubled Pairs
Given an array of even length, check if it can be reordered to satisfy a specific doubling condition.
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…
Tallest Billboard
Solve the Tallest Billboard problem by using dynamic programming to find the maximum equal height for two disjoint rod s…
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…
Regions Cut By Slashes
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
Delete Columns to Make Sorted III
The problem requires minimizing deletions to ensure all strings are lexicographically sorted. Use dynamic programming fo…
N-Repeated Element in Size 2N Array
Find the element that is repeated exactly N times in a 2N-sized array using array scanning and hash lookups.
Maximum Width Ramp
Find the maximum width of a ramp where nums[i] <= nums[j] for i < j using a two-pointer approach.
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.
Vowel Spellchecker
Implement a spellchecker that matches queries to a wordlist using exact, case-insensitive, and vowel-error rules efficie…
Pancake Sorting
Sort an array using pancake flips, leveraging two-pointer scanning and invariant tracking to iteratively position the la…
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…
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.
Odd Even Jump
Determine the number of valid starting indices in an array where you can reach the end with alternating odd and even jum…
Largest Perimeter Triangle
Given an integer array, find the largest perimeter of a triangle formed from three of these lengths.
Squares of a Sorted Array
The problem involves squaring elements of a sorted array and returning the squares in non-decreasing order.
Longest Turbulent Subarray
Find the length of the longest subarray where element comparisons alternate, using state transition dynamic programming …
Unique Paths III
Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…
Triples with Bitwise AND Equal To Zero
Count all index triples in an array where the bitwise AND of their elements equals zero using efficient bit manipulation…
Minimum Cost For Tickets
Solve the Minimum Cost For Tickets problem using state transition dynamic programming for optimal travel ticket purchase…
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…
Interval List Intersections
This problem requires finding the intersection of two lists of intervals using a two-pointer technique with invariant tr…
Add to Array-Form of Integer
Compute the sum of an integer and a number represented as an array, efficiently handling digit carries and array travers…
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…
Subarrays with K Different Integers
Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.
Rotting Oranges
Given a grid with fresh and rotten oranges, return the minimum time for all oranges to rot or -1 if impossible.
Minimum Number of K Consecutive Bit Flips
Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…
Number of Squareful Arrays
Count the number of squareful arrays from the given list of integers by checking adjacent pairs' sums for perfect square…
Find the Town Judge
Find the Town Judge is an easy LeetCode problem that challenges you to identify a town judge from trust relationships us…
Available Captures for Rook
This problem involves finding the number of pawns a rook can capture on a chessboard, considering obstacles like bishops…
Minimum Cost to Merge Stones
Minimize the cost to merge stones with k consecutive piles using dynamic programming to achieve the optimal solution.
Grid Illumination
Grid Illumination uses an array scanning approach with hash lookups to check illuminated cells in a large grid based on …
Find Common Characters
Return an array of common characters from all strings in the given list of words, including duplicates.
Max Consecutive Ones III
Find the longest consecutive ones in a binary array by optimally flipping at most k zeros using sliding window technique…
Maximize Sum Of Array After K Negations
Maximize the sum of an integer array after exactly k negations using a greedy approach and invariant tracking for optima…
Minimum Domino Rotations For Equal Row
Minimize domino rotations to make either row identical in the problem of Minimum Domino Rotations For Equal Row.
Construct Binary Search Tree from Preorder Traversal
Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.
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.
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…
Partition Array Into Three Parts With Equal Sum
Determine if an array can be partitioned into three non-empty parts with equal sum using greedy choice and validation.
Best Sightseeing Pair
Compute the maximum sightseeing score efficiently using state transition dynamic programming and single-pass array itera…
Binary Prefix Divisible By 5
Determine which binary prefixes of a given array are divisible by 5 using bit manipulation for efficient checks.
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.
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…
Camelcase Matching
Camelcase Matching is a medium difficulty problem where you match queries to a given pattern by inserting lowercase lett…
Video Stitching
Solve the "Video Stitching" problem using state transition dynamic programming to cover a sporting event with minimum cl…
Longest Arithmetic Subsequence
Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.
Two City Scheduling
Two City Scheduling requires selecting optimal city assignments for 2n people to minimize total travel costs efficiently…
Matrix Cells in Distance Order
Compute all matrix cell coordinates sorted by Manhattan distance from a given center using array and math techniques eff…
Maximum Sum of Two Non-Overlapping Subarrays
Find the maximum sum of two non-overlapping subarrays by efficiently using state transition dynamic programming.
Stream of Characters
Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…
Coloring A Border
Given a grid and a starting cell, color all border cells of the connected component using DFS while preserving interior …
Uncrossed Lines
The Uncrossed Lines problem involves finding the maximum number of non-intersecting lines that can be drawn between two …
Escape a Large Maze
The 'Escape a Large Maze' problem involves navigating a massive grid with blocked squares and finding if a target can be…
Valid Boomerang
Determine if three points on a 2D plane form a boomerang, based on distinctness and non-collinearity.
Minimum Score Triangulation of Polygon
Compute the minimum total score to triangulate a convex polygon using state transition dynamic programming on vertex val…
Moving Stones Until Consecutive II
Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…
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…
Last Stone Weight
In the 'Last Stone Weight' problem, we smash the two heaviest stones until one remains, using heaps or sorting.
Longest String Chain
Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…
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…
Height Checker
Determine how many students are out of place in a line by comparing their heights to the sorted expected order efficient…
Grumpy Bookstore Owner
Maximize satisfied customers in a bookstore by strategically suppressing the owner's grumpy minutes using a sliding wind…
Previous Permutation With One Swap
Find the lexicographically largest permutation smaller than the given array using exactly one swap, leveraging a greedy …
Distant Barcodes
Rearrange barcodes in an array so that no two adjacent elements are equal, using a greedy approach and hash table for ef…
Flip Columns For Maximum Number of Equal Rows
Maximize the number of equal rows in a binary matrix by flipping any number of columns.
Adding Two Negabinary Numbers
Add two numbers represented in negabinary format and return the result in the same format.
Number of Submatrices That Sum to Target
Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…
Duplicate Zeros
Duplicate each zero in a fixed-length array in place, shifting elements right using a two-pointer scanning approach effi…
Largest Values From Labels
Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.
Shortest Path in Binary Matrix
Find the shortest clear path in a binary matrix using BFS, carefully handling obstacles and diagonal movements for effic…
Statistics from a Large Sample
Calculate minimum, maximum, mean, median, and mode from a large sample represented by an array of counts.
Car Pooling
Determine if a car can handle multiple trips without exceeding its capacity using array sorting and event simulation tec…
Find in Mountain Array
Find in Mountain Array requires locating a target using binary search over a peak-structured array efficiently in intera…
Filling Bookcase Shelves
Determine the minimum total height of a bookcase by placing books in order using state transition dynamic programming.
Corporate Flight Bookings
Solve Corporate Flight Bookings by marking range changes once, then building final seat totals with a single prefix sum …
Delete Nodes And Return Forest
Delete nodes from a binary tree using array scanning and hash lookup to return the remaining forest efficiently.
Relative Sort Array
Sort arr1 by the relative order of arr2, with remaining elements placed in ascending order.
Longest Well-Performing Interval
The Longest Well-Performing Interval problem challenges you to find the longest subarray where tiring days exceed non-ti…
Smallest Sufficient Team
Find the smallest subset of people covering all required skills using bitmask dynamic programming for efficient state tr…
Number of Equivalent Domino Pairs
Count all pairs of dominoes that are equivalent by scanning the array and using a hash table for fast lookup.
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…
Maximum of Absolute Value Expression
Calculate the largest sum of absolute differences across two arrays and their indices using an efficient pattern-based a…
Largest 1-Bordered Square
Find the largest square of 1s with 1s on its borders in a binary grid using dynamic programming.
Stone Game II
Stone Game II is a dynamic programming problem where Alice and Bob alternate taking stones from piles to maximize their …
Decrease Elements To Make Array Zigzag
Transform any integer array into a zigzag pattern with minimal decrements using a targeted greedy approach and invariant…
Snapshot Array
Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…
Online Majority Element In Subarray
Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.
Find Words That Can Be Formed by Characters
Compute the total length of words that can be fully constructed from given characters using array scanning and hash mapp…
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…
Invalid Transactions
Detect invalid transactions by scanning arrays and cross-checking with hash tables for time, amount, and city conflicts …
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…
Can Make Palindrome from Substring
Given a string and queries, determine if a substring can be rearranged and modified to form a palindrome.
Number of Valid Words for Each Puzzle
Solve the "Number of Valid Words for Each Puzzle" problem with array scanning and hash lookup to efficiently count valid…
Distance Between Bus Stops
Compute the minimal distance between two bus stops on a circular route using an array-driven solution approach.
Maximum Subarray Sum with One Deletion
Find the maximum sum of a subarray with at most one deletion in this dynamic programming problem.
Make Array Strictly Increasing
Determine the minimum operations to transform arr1 into a strictly increasing sequence using values from arr2 efficientl…
K-Concatenation Maximum Sum
Solve the K-Concatenation Maximum Sum problem using dynamic programming and optimal sub-array sum calculation.
Minimum Absolute Difference
Find all pairs with the minimum absolute difference between two elements in an array, and return them in ascending order…
Smallest String With Swaps
Find the lexicographically smallest string by swapping characters in given pairs of indices.
Unique Number of Occurrences
Determine if each integer in an array occurs a unique number of times using efficient hash-based counting and verificati…
Minimum Moves to Reach Target with Rotations
Find the minimum moves for a 2-cell snake to reach the bottom-right corner using rotations and BFS traversal in a grid.
Minimum Cost to Move Chips to The Same Position
Compute the minimum cost to move all chips to one position using parity-based greedy moves efficiently.
Longest Arithmetic Subsequence of Given Difference
Find the longest arithmetic subsequence with a given difference using dynamic programming and hash tables.
Path with Maximum Gold
Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.
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…
Dice Roll Simulation
Calculate all valid sequences of n dice rolls with consecutive roll constraints using state transition dynamic programmi…
Maximum Equal Frequency
Find the longest prefix of an array where removing one element makes all numbers appear equally, using efficient hash tr…
Check If It Is a Straight Line
Determine if a series of coordinates form a straight line on a 2D plane using geometry and mathematical principles.
Remove Sub-Folders from the Filesystem
Remove sub-folders in a filesystem by filtering out folders nested inside other folders.
Maximum Profit in Job Scheduling
Compute the maximum profit from non-overlapping jobs using state transition dynamic programming with sorted arrays and b…
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…
Count Number of Nice Subarrays
The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.
Check If It Is a Good Array
Determine if a given array of positive integers can generate 1 using integer multiples of any subset, leveraging number …
Cells with Odd Values in a Matrix
This problem involves updating a matrix based on given indices and counting cells with odd values afterward.
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…
Number of Closed Islands
Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.
Maximum Score Words Formed by Letters
Calculate the highest total score by selecting words from a list using available letters, respecting individual letter s…
Shift 2D Grid
Shift 2D Grid requires shifting elements of a matrix by a given number of times, simulating step-by-step movement.
Greatest Sum Divisible by Three
Find the maximum sum divisible by three from a given array using dynamic programming and state transition.
Minimum Moves to Move a Box to Their Target Location
Solve the minimum moves to push a box to its target using BFS and priority handling in a grid-based warehouse layout eff…
Minimum Time Visiting All Points
Calculate the minimum seconds required to visit all given 2D points in order using optimal diagonal or straight moves.
Count Servers that Communicate
Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…
Search Suggestions System
Design a search suggestion system that provides the top three lexicographically smallest products matching a search word…
Find Winner on a Tic Tac Toe Game
Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…
Count Square Submatrices with All Ones
Count the number of square submatrices with all ones in a given binary matrix using dynamic programming.
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…
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.
Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…
Element Appearing More Than 25% In Sorted Array
Identify the integer occurring more than 25% in a sorted array using a precise array-driven search strategy for efficien…
Remove Covered Intervals
Remove all intervals fully covered by another using sorting and linear traversal, counting only distinct remaining inter…
Minimum Falling Path Sum II
Find the minimum sum of a falling path in a square matrix using dynamic programming while avoiding same-column selection…
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…
Shortest Path in a Grid with Obstacles Elimination
Find the shortest path in a grid with obstacles, allowing the elimination of up to k obstacles using BFS.
Find Numbers with Even Number of Digits
Count the integers in an array that have an even number of digits using a direct array traversal with digit math.
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…
Maximum Candies You Can Get from Boxes
Collect maximum candies from boxes by exploring initially available boxes and using keys to unlock additional ones effic…
Replace Elements with Greatest Element on Right Side
Replace every element in an array with the greatest element on its right side, and replace the last element with -1.
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.
Number of Paths with Max Score
Calculate the maximum score path and count all valid routes in a square board with obstacles using dynamic programming.
Find N Unique Integers Sum up to Zero
Generate an array of n unique integers that sum to zero using a symmetric pairing strategy to ensure balance.
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…
Verbal Arithmetic Puzzle
Check if a verbal arithmetic equation can be solved using a valid digit-letter mapping.
XOR Queries of a Subarray
Compute XOR results for multiple subarray queries using efficient prefix XOR to reduce repeated computation overhead in …
Get Watched Videos by Your Friends
Find videos watched by friends up to a given level and return them sorted by frequency and alphabetically.
Decompress Run-Length Encoded List
Decompress a run-length encoded list by expanding each pair into repeated values based on frequency.
Matrix Block Sum
Compute a matrix where each cell contains the sum of all elements within k-distance blocks using prefix sums efficiently…
Print Words Vertically
Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…
Minimum Number of Taps to Open to Water a Garden
Determine the minimum number of taps to water an entire garden using state transition dynamic programming and interval c…
Sort the Matrix Diagonally
Sort each diagonal of a matrix in ascending order, applying sorting and matrix traversal techniques.
Reverse Subarray To Maximize Array Value
Maximize the value of an array by reversing a subarray, focusing on greedy choices and invariant validation.
Rank Transform of an Array
Transform the elements of an array into their ranks, where the rank represents the size order of the elements.
Filter Restaurants by Vegan-Friendly, Price and Distance
Filter restaurants by vegan-friendly status, price, and distance, and sort them by rating and ID.
Minimum Difficulty of a Job Schedule
Schedule jobs into multiple days to minimize the difficulty of the schedule using dynamic programming and state transiti…
The K Weakest Rows in a Matrix
Find the k weakest rows in a binary matrix where rows contain soldiers and civilians, using sorting and binary search te…
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…
Jump Game V
Jump Game V is a hard dynamic programming problem that focuses on maximizing jumps between indices in an array.
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.
Jump Game IV
Jump Game IV requires minimizing steps to reach the last index using jumps across equal values and neighbors efficiently…
Check If N and Its Double Exist
Solve Check If N and Its Double Exist by scanning once and checking doubles or halves in a hash set.
Maximum Students Taking Exam
Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…
Count Negative Numbers in a Sorted Matrix
Count Negative Numbers in a Sorted Matrix requires counting negative numbers in a matrix sorted in non-increasing order …
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…
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.
Construct Target Array With Multiple Sums
This problem requires constructing a target array from an array of ones, using multiple sum operations and a priority qu…
Sort Integers by The Number of 1 Bits
Sort an array of integers by the number of 1's in their binary representation and then by their value in case of ties.
Apply Discount Every n Orders
Compute customer bills with periodic discounts efficiently using array scanning and hash mapping for fast product price …
Largest Multiple of Three
Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…
How Many Numbers Are Smaller Than the Current Number
In this problem, you need to determine how many numbers are smaller than each element in an array, focusing on array sca…
Rank Teams by Votes
Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…
Minimum Cost to Make at Least One Valid Path in a Grid
Determine the minimum cost to create at least one valid path from the top-left to bottom-right in a directional grid.
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…
Lucky Numbers in a Matrix
The Lucky Numbers in a Matrix problem involves finding elements that are the minimum in their row and maximum in their c…
Design a Stack With Increment Operation
Implement a stack that supports push, pop, and targeted increment operations efficiently using array-based state managem…
Maximum Performance of a Team
Maximize the performance of a team by selecting up to k engineers with the highest performance based on speed and effici…
Find the Distance Value Between Two Arrays
Calculate the distance value between two integer arrays by determining how many elements in arr1 don't have a close coun…
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…
Pizza With 3n Slices
Maximize your pizza slice sum from a 3n-sized circular array using state transition dynamic programming efficiently.
Create Target Array in the Given Order
Learn how to efficiently create a target array by inserting elements at specified indices using array simulation techniq…
Four Divisors
Compute the sum of all divisors for numbers in an array that have exactly four divisors using array and math techniques.
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.
Find Lucky Integer in an Array
Identify the largest lucky integer in an array by counting frequencies and comparing values with their occurrences effic…
Count Number of Teams
Count the number of valid three-soldier teams using ratings with a state transition dynamic programming approach efficie…
Reducing Dishes
Maximize the sum of like-time coefficients by optimally choosing dishes to prepare in this dynamic programming problem.
Minimum Subsequence in Non-Increasing Order
Find the minimum subsequence in non-increasing order such that its sum exceeds the sum of non-included elements.
Stone Game III
Stone Game III is a challenging dynamic programming problem based on game theory and state transition logic.
String Matching in an Array
Identify all strings in an array that appear as substrings of other strings, focusing on array and string matching patte…
Queries on a Permutation With Key
This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.
Minimum Value to Get Positive Step by Step Sum
Find the minimum starting value to ensure the step-by-step sum of an array is always at least 1.
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…
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.
Diagonal Traverse II
Traverse a jagged 2D array diagonally by grouping elements with equal row and column sums efficiently using sorting and …
Constrained Subsequence Sum
Solve the Constrained Subsequence Sum problem using dynamic programming, sliding window, and priority queues to maximize…
Kids With the Greatest Number of Candies
Determine which kids, after receiving extra candies, will have the greatest number of candies in a group.
Number of Ways to Wear Different Hats to Each Other
Calculate all unique assignments of hats to people using state transition dynamic programming with bitmasking for collis…
Destination City
Find the destination city from a list of paths where each path connects two cities. The city with no outgoing path is th…
Check If All 1's Are at Least Length K Places Away
Check if all 1's in a binary array are at least k places away from each other.
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…
Find the Kth Smallest Sum of a Matrix With Sorted Rows
Find the kth smallest sum in a matrix with sorted rows using binary search and a heap-based approach.
Build an Array With Stack Operations
Simulate stack operations to match a target array while processing numbers from 1 to n.
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…
Number of Ways of Cutting a Pizza
This problem challenges you to determine the number of valid ways to cut a pizza into pieces with apples using dynamic p…
Form Largest Integer With Digits That Add up to Target
Maximize the integer you can paint with given digit costs under a target sum, using dynamic programming to optimize the …
Number of Students Doing Homework at a Given Time
Count the number of students doing homework at a given time using an array-driven solution approach.
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…
Maximum Number of Darts Inside of a Circular Dartboard
Maximize the number of darts on a circular dartboard given dart positions and radius.
Max Dot Product of Two Subsequences
Solve Max Dot Product of Two Subsequences with state transition dynamic programming that enforces a non-empty pairing de…
Make Two Arrays Equal by Reversing Subarrays
Solve Make Two Arrays Equal by Reversing Subarrays by checking whether target and arr contain the same values with match…
Cherry Pickup II
Maximize cherry collection in a grid using two robots with careful state transition dynamic programming to optimize path…
Maximum Product of Two Elements in an Array
Find the maximum product of two elements in an array by carefully selecting indices and leveraging sorting for efficienc…
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.
Probability of a Two Boxes Having The Same Number of Distinct Balls
Compute the probability that two boxes contain the same number of distinct balls using careful combinatorial and DP meth…
Shuffle the Array
Shuffle the Array requires an efficient approach to rearrange elements using an array-driven solution strategy with two …
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.
Design Browser History
Implement a browser history tracker with back, forward, and visit operations using linked-list pointer manipulation effi…
Paint House III
Solve Paint House III using state transition dynamic programming to minimize painting costs while forming exact neighbor…
Final Prices With a Special Discount in a Shop
Calculate final prices with discounts applied in a shop using a stack-based state management approach to find the correc…
Subrectangle Queries
Implement the SubrectangleQueries class to handle dynamic updates and value queries on a 2D rectangle.
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 …
Allocate Mailboxes
Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…
Running Sum of 1d Array
Calculate the running sum of a given 1D array by updating each element to the sum of itself and all previous elements.
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…
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…
Making File Names Unique
This problem requires creating unique folder names by appending suffixes to duplicate names using an array scanning and …
Avoid Flood in The City
This problem asks you to avoid flooding by deciding when to dry lakes between rain events.
Average Salary Excluding the Minimum and Maximum Salary
Calculate the average salary of employees, excluding the highest and lowest salaries, from an array of unique salaries.
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.
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 …
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…
Max Value of Equation
Max Value of Equation asks to find the maximum value of a specific equation on a set of 2D points using sliding window t…
Can Make Arithmetic Progression From Sequence
Determine if a given array can be rearranged into a valid arithmetic progression using sorting and consecutive differenc…
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.
Count Submatrices With All Ones
Count Submatrices With All Ones is a dynamic programming problem focusing on submatrix counting using an efficient row-b…
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…
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.
Number of Good Pairs
Count all index pairs in an array where elements match and the first index is smaller, using hash-based scanning efficie…
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…
Best Position for a Service Centre
Find the optimal service center position in a city by minimizing the sum of Euclidean distances to all customers.
Find a Value of a Mysterious Function Closest to Target
In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.
Number of Sub-arrays With Odd Sum
Count the number of subarrays with an odd sum using dynamic programming and prefix sum techniques.
Minimum Number of Increments on Subarrays to Form a Target Array
The problem asks for the minimum number of operations to transform an initial array of zeros into a target array using s…
Shuffle String
Reorder characters in a string using a given indices array to reconstruct the intended output efficiently and correctly.
Count Good Triplets
Count Good Triplets requires identifying all triplets in an array that satisfy multiple absolute difference constraints …
Find the Winner of an Array Game
Determine the integer that wins an array game by achieving k consecutive victories through simulated pairwise comparison…
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…
Get the Maximum Score
Find the maximum possible score from two sorted arrays with a dynamic programming approach, leveraging partitioning and …
Kth Missing Positive Number
Find the kth missing positive integer in a strictly increasing array using binary search over the answer space efficient…
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…
Minimum Cost to Cut a Stick
Find the minimum cost to cut a stick into segments at specified positions using dynamic programming and sorting.
Three Consecutive Odds
Determine if an integer array contains three consecutive odd numbers using a direct array-driven solution strategy for f…
Magnetic Force Between Two Balls
Maximize the minimum magnetic force between balls by strategically placing them in baskets using binary search on positi…
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 …
Detect Cycles in 2D Grid
Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.
Most Visited Sector in a Circular Track
Determine which sectors on a circular track are visited most frequently using array and simulation techniques efficientl…
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…
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…
Stone Game V
In Stone Game V, Alice divides stones into rows to maximize her score, using a dynamic programming approach to try all d…
Detect Pattern of Length M Repeated K or More Times
Determine if a subarray of length m repeats k or more consecutive times in a given integer array efficiently.
Maximum Length of Subarray With Positive Product
Given an array, find the maximum length of a subarray with a positive product using dynamic programming.
Minimum Number of Days to Disconnect Island
Find the minimum number of days to disconnect an island in a grid using depth-first search.
Number of Ways to Reorder Array to Get Same BST
Determine the number of ways to reorder an array to get the same binary search tree (BST) from its insertion order.
Matrix Diagonal Sum
Calculate the sum of both primary and secondary diagonals in a square matrix while avoiding double-counting overlaps.
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…
Count All Possible Routes
This problem requires counting all possible routes between cities using fuel efficiently with state transition dynamic p…
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 …
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.
Special Positions in a Binary Matrix
Identify all special positions in a binary matrix where a 1 has no other 1s in its row or column, ensuring optimal array…
Count Unhappy Friends
Determine the number of unhappy friends in paired arrangements using array-based simulation for preference violations.
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 …
Sum of All Odd Length Subarrays
Calculate the sum of all odd-length subarrays in a given integer array using efficient array and math strategies.
Maximum Sum Obtained of Any Permutation
Maximize the total sum of requests on nums by greedily assigning larger numbers to most frequently requested indices.
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…
Strange Printer II
Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…
Maximum Non Negative Product in a Matrix
Find the maximum non-negative product path in a matrix using dynamic programming and state transition.
Minimum Cost to Connect Two Groups of Points
Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.
Crawler Log Folder
Simulate folder navigation based on a list of operations to determine the current folder depth.
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…
Maximum Number of Achievable Transfer Requests
Find the maximum number of achievable transfer requests between buildings with constraints on net employee transfers.
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…
Find Valid Matrix Given Row and Column Sums
Given row and column sums, find any valid matrix of non-negative integers that satisfies them.
Find Servers That Handled Most Number of Requests
Given k servers and a series of requests, find the busiest server(s) using greedy strategies and efficient server tracki…
Special Array With X Elements Greater Than or Equal X
Determine if an array has exactly x elements greater than or equal to x using binary search over the answer space.
Maximum Number of Visible Points
Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…
Mean of Array After Removing Some Elements
Calculate the trimmed mean by removing the lowest and highest 5% of elements in an array using sorting for accuracy and …
Coordinate With Maximum Network Quality
Determine the coordinate with the maximum network quality by summing signal strengths from all reachable towers efficien…
Best Team With No Conflicts
Find the highest score basketball team by choosing players without conflicts in age and score using dynamic programming.
Graph Connectivity With Threshold
In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…
Slowest Key
Determine which key had the longest press duration in a sequence using array indices and string mapping, resolving ties …
Arithmetic Subarrays
Determine whether subarrays of a given array can be rearranged to form arithmetic sequences using array scanning and has…
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…
Rank Transform of a Matrix
Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…
Sort Array by Increasing Frequency
Sort Array by Increasing Frequency requires counting each element and ordering them by frequency, breaking ties with des…
Widest Vertical Area Between Two Points Containing No Points
Find the maximum width of a vertical area between points with no points inside using array sorting efficiently.
Number of Ways to Form a Target String Given a Dictionary
Calculate the number of ways to form a target string using words of equal length via state transition dynamic programmin…
Check Array Formation Through Concatenation
Determine if an array can be formed by concatenating subarrays without reordering individual elements, using hash lookup…
Furthest Building You Can Reach
Furthest Building You Can Reach explores a greedy approach with heap-based optimization to find the maximum reachable bu…
Kth Smallest Instructions
Find the kth smallest lexicographic instruction sequence for reaching a destination in a grid using state transition dyn…
Get Maximum in Generated Array
Compute the maximum value in a generated array using defined recurrence rules, leveraging array simulation techniques ef…
Sell Diminishing-Valued Colored Balls
Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.
Create Sorted Array through Instructions
The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.
Defuse the Bomb
Defuse the Bomb uses a sliding window to update a circular array based on a key, with efficient state updates.
Minimum Jumps to Reach Home
Find the minimum number of jumps needed to reach a target position while avoiding forbidden positions.
Distribute Repeating Integers
Determine if you can allocate integers to satisfy customer quantities using state transition dynamic programming techniq…
Design an Ordered Stream
Design an Ordered Stream that returns values in increasing order based on unique integer IDs with efficient insertion an…
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.
Check If Two String Arrays are Equivalent
Determine if two string arrays form identical strings by concatenating elements in order, handling subtle array-length m…
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.
Minimum Initial Energy to Finish Tasks
Determine the minimum initial energy needed to finish all tasks using a greedy ordering based on required versus actual …
Design Front Middle Back Queue
Implement a queue that efficiently handles push and pop operations at the front, middle, and back using pointer manipula…
Minimum Number of Removals to Make Mountain Array
Solve the problem of finding the minimum number of removals to make a given array a mountain array using dynamic program…
Richest Customer Wealth
Calculate the richest customer's wealth by summing the amounts in each customer's bank accounts in a matrix.
Find the Most Competitive Subsequence
Identify the lexicographically smallest subsequence of size k using stack-based greedy selection in array traversal.
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.
Minimize Deviation in Array
Given a positive integer array, repeatedly double or halve elements to minimize the difference between its largest and s…
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.
Minimum Incompatibility
Optimize the sum of incompatibilities when distributing an array into subsets with unique elements.
Count the Number of Consistent Strings
Count the number of strings fully composed of allowed characters using array scanning and hash lookup for efficiency.
Sum of Absolute Differences in a Sorted Array
Calculate the sum of absolute differences between each element and others in a sorted array efficiently.
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 …
Delivering Boxes from Storage to Ports
Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…
Stone Game VII
Maximize score difference in a two-player turn-based stone removal game using state transition dynamic programming.
Maximum Height by Stacking Cuboids
Maximize the height of stacked cuboids by strategically rotating and stacking them using dynamic programming.
Maximum Erasure Value
Maximize the score by erasing a subarray with unique elements in an array of integers.
Jump Game VI
Jump Game VI challenges you to maximize your score while jumping through an array using state transition dynamic program…
Checking Existence of Edge Length Limited Paths
Solve the problem of checking if there exists a path between two nodes under edge length constraints using efficient tec…
Number of Students Unable to Eat Lunch
Simulate a queue of students with sandwich preferences and determine how many can't eat based on available sandwiches.
Average Waiting Time
Compute the average waiting time for customers using array traversal and simulation of a single chef processing orders s…
Minimum Adjacent Swaps for K Consecutive Ones
Find the minimum number of adjacent swaps to gather k consecutive ones in a binary array using sliding window logic.
Maximum Number of Eaten Apples
Maximize apples eaten by choosing the best apples first, considering their rot days and available days to eat them.
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…
Maximum XOR With an Element From Array
Solve the Maximum XOR With an Element From Array problem by efficiently finding the maximum XOR for each query using bit…
Maximum Units on a Truck
Maximize total units loaded on a truck by choosing boxes greedily based on highest units per box within truck capacity l…
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.
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 …
Minimum Operations to Make a Subsequence
Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…
Construct the Lexicographically Largest Valid Sequence
Construct the Lexicographically Largest Valid Sequence problem involves finding the largest sequence with backtracking a…
Decode XORed Array
Recover the original integer array from its XOR-encoded version using direct bitwise manipulation and sequential reconst…
Minimize Hamming Distance After Swap Operations
Solve Minimize Hamming Distance After Swap Operations by grouping swappable indices and matching value counts inside eac…
Find Minimum Time to Finish All Jobs
Minimize the maximum working time of k workers by optimally assigning jobs, leveraging dynamic programming and bit manip…
Number Of Rectangles That Can Form The Largest Square
Determine how many rectangles can be trimmed to form the largest possible square using an array-driven solution strategy…
Tuple with Same Product
Given an array of distinct integers, return the number of tuples where the product of two pairs is the same.
Largest Submatrix With Rearrangements
Rearrange columns of a binary matrix to find the largest submatrix of 1s.
Cat and Mouse II
Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…
Find the Highest Altitude
Find the highest altitude after a series of altitude changes during a road trip using prefix sum technique.
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.
Decode XORed Permutation
Decode XORed Permutation uses prefix reconstruction with global XOR to recover the hidden odd-length permutation in line…
Count Ways to Make Array With Product
Determine the number of arrays of size n where the product equals k using prime factorization and combinatorial DP techn…
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…
Restore the Array From Adjacent Pairs
Restore the Array From Adjacent Pairs reconstructs a sequence using adjacent element pairs. Efficient hash lookups and a…
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.
Sum of Unique Elements
Given an array, find the sum of all its unique elements by identifying those that appear only once.
Maximum Absolute Sum of Any Subarray
Solve for the maximum absolute sum of any subarray using dynamic programming and understanding state transitions.
Maximum Number of Events That Can Be Attended II
Determine the maximum sum of event values you can collect by attending at most k non-overlapping events using DP.
Check if Array Is Sorted and Rotated
Determine if a given integer array is sorted in non-decreasing order and then rotated, handling duplicates correctly.
Closest Subsequence Sum
Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…
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.
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…
Map of Highest Peak
Solve the Map of Highest Peak problem using breadth-first search to assign heights based on proximity to water cells.
Tree of Coprimes
Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…
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…
Maximum Score from Performing Multiplication Operations
Solve the Maximum Score from Performing Multiplication Operations problem using dynamic programming and state transition…
Count Items Matching a Rule
Count Items Matching a Rule is an easy problem that tests array and string manipulation with conditions based on specifi…
Closest Dessert Cost
Find the closest dessert cost to a target by selecting from a list of base flavors and topping combinations using dynami…
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…
Car Fleet II
Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…
Find Nearest Point That Has the Same X or Y Coordinate
Find the nearest point with the same x or y coordinate using Manhattan distance. Return its index or -1 if none exists.
Count Pairs Of Nodes
Given a graph with nodes and edges, count pairs of nodes where the degree sum exceeds a given threshold for each query.
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…
Make the XOR of All Segments Equal to Zero
Determine the minimum changes needed in an array so all size-k segments XOR to zero using DP and bit manipulation.
Maximum Average Pass Ratio
Maximize the average pass ratio by assigning extra guaranteed-passing students using a greedy heap strategy for optimal …
Maximum Score of a Good Subarray
Maximize the score of a good subarray using binary search to explore the valid answer space with a focus on two-pointer …
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.
Maximize Score After N Operations
Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …
Maximum Ascending Subarray Sum
Solve Maximum Ascending Subarray Sum by scanning once, extending rising runs, and resetting the running sum at each drop…
Number of Orders in the Backlog
Determine the total number of unfulfilled buy and sell orders using heaps to simulate backlog processing efficiently in …
Count Pairs With XOR in a Range
Count all pairs in an array whose XOR falls within a given range using efficient bit manipulation techniques and a trie …
Minimum Number of Operations to Reinitialize a Permutation
Find the minimum number of operations to reinitialize a permutation of size n using specific operations.
Evaluate the Bracket Pairs of a String
Quickly evaluate a string with bracketed keys using array scanning and hash table lookups for efficient replacements.
Sentence Similarity III
Sentence Similarity III asks if one sentence can be transformed into another by inserting a sentence inside it.
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…
Maximum Number of Groups Getting Fresh Donuts
Reorder groups to maximize happy customers by using state transition dynamic programming with bitmasking for optimal bat…
Truncate Sentence
Truncate a sentence to contain only the first k words by converting it into an array of words.
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.
Minimum Absolute Sum Difference
Minimize the absolute sum difference between two integer arrays by replacing at most one element from the first array.
Number of Different Subsequences GCDs
Given an array of positive integers, find the number of different subsequences' GCDs.
Sign of the Product of an Array
Determine the sign of a product from an integer array using a single pass without computing the full product.
Find the Winner of the Circular Game
Find the winner of a circular game by simulating the elimination process with a queue-driven approach.
Minimum Sideway Jumps
Solve the Minimum Sideway Jumps problem using state transition dynamic programming to minimize side jumps while navigati…
Minimum Operations to Make the Array Increasing
Calculate the minimum number of increments required to transform a given integer array into a strictly increasing sequen…
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…
Maximum XOR for Each Query
Find the maximum XOR for each query based on a sorted array and bit manipulation.
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.
Single-Threaded CPU
Simulate task processing with a single-threaded CPU by sorting and prioritizing tasks based on arrival and processing ti…
Find XOR Sum of All Pairs Bitwise AND
Compute the XOR sum of all pairwise ANDs between two integer arrays using array and bitwise math techniques efficiently.
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…
Maximum Building Height
Find the maximum building height in a city given height restrictions for specific buildings.
Maximum Element After Decreasing and Rearranging
Determine the maximum value in an array after decreasing elements and rearranging using a greedy invariant approach.
Closest Room
Find the closest hotel room meeting minimum size requirements using binary search over the valid answer space efficientl…
Minimum Distance to the Target Element
Solve Minimum Distance to the Target Element by scanning the array and tracking the smallest distance from start.
Minimum Interval to Include Each Query
Find the smallest interval containing each query efficiently using binary search.
Maximum Population Year
Find the earliest year with the highest population using an array plus counting approach.
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.
Maximum Subarray Min-Product
The problem asks to find the maximum min-product of any non-empty subarray of nums.
Rotating the Box
Rotate a box represented by a character matrix, letting stones fall under gravity using precise two-pointer scanning and…
Sum of Floored Pairs
The problem asks to calculate the sum of floor divisions for all pairs in a given integer array, using an efficient meth…
Sum of All Subset XOR Totals
Compute the sum of all subset XOR totals using a backtracking search with pruning for arrays of small size.
Finding Pairs With a Certain Sum
Efficiently track and count pairs across two arrays using array scanning plus hash lookup to support dynamic updates.
Minimum Speed to Arrive on Time
This problem asks to find the minimum speed of trains to reach on time using binary search.
Stone Game VIII
Stone Game VIII requires calculating maximum score difference using state transition dynamic programming on prefix sums …
Minimize Maximum Pair Sum in Array
Minimize the maximum pair sum in an array by optimally pairing its elements.
Get Biggest Three Rhombus Sums in a Grid
Find the three largest distinct rhombus sums from a given grid using array and math techniques.
Minimum XOR Sum of Two Arrays
Minimize the XOR sum of two integer arrays by rearranging elements using dynamic programming and bit manipulation.
Process Tasks Using Servers
Assign tasks to servers efficiently using arrays and heaps, resolving ties by weight and index while tracking availabili…
Minimum Skips to Arrive at Meeting On Time
Solve the problem of minimizing skips while traveling to arrive on time, using dynamic programming and state transitions…
Determine Whether Matrix Can Be Obtained By Rotation
Determine if a binary matrix can be transformed into another by rotating it 90 degrees multiple times.
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…
Minimum Space Wasted From Packaging
Minimize the wasted space when packaging items into boxes, considering package and box size constraints.
Check if All the Integers in a Range Are Covered
Check if all integers in the range [left, right] are covered by intervals in a given set of ranges.
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.
Largest Magic Square
Find the side length of the largest magic square in a matrix where row, column, and diagonal sums are equal.
Maximum Number of Removable Characters
Use binary search and a subsequence check to find the largest removable prefix that still keeps p inside s.
Merge Triplets to Form Target Triplet
Determine if target triplet can be formed by merging given triplets using greedy selection and invariant checks.
Find a Peak Element II
Locate any peak in a 2D matrix using binary search across rows or columns for efficient discovery and verification.
Count Sub Islands
Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…
Minimum Absolute Difference Queries
Compute minimum absolute differences for subarrays efficiently using array scanning and hash table lookups, leveraging b…
Remove One Element to Make the Array Strictly Increasing
Determine if removing a single element from an array can make it strictly increasing, using a careful index check approa…
Maximum Alternating Subsequence Sum
Maximize alternating subsequence sum with dynamic programming and state transitions in an array.
Design Movie Rental System
Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.
Maximum Product Difference Between Two Pairs
Find the maximum product difference between two pairs in an integer array using sorting for optimal selection.
Cyclically Rotating a Grid
This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …
Build Array from Permutation
The problem asks to build an array from a given permutation using an efficient approach.
Eliminate Maximum Number of Monsters
Eliminate monsters by strategically using a weapon in a video game to stop them before they reach your city.
Longest Common Subpath
The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…
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.
Minimum Cost to Reach Destination in Time
Minimize the travel cost in a graph while adhering to a time constraint using state transition dynamic programming.
Concatenation of Array
This problem asks you to create an array of double the size, where each element is repeated twice in sequence.
Add Minimum Number of Rungs
Determine the fewest rungs to add to climb a strictly increasing ladder using a greedy step-by-step approach.
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…
Maximum Genetic Difference Query
Find the maximum genetic difference along paths in a tree using array scanning and hash lookups with XOR calculations.
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…
Describe the Painting
Solve the problem of describing a painted segment with mixed colors using array scanning and hash table lookups.
Number of Visible People in a Queue
Compute how many people each person in a queue can see to their right using efficient stack-based state management.
Largest Number After Mutating Substring
Find the largest integer by mutating a substring of a number using a mapping array for each digit.
Maximum Compatibility Score Sum
Assign students to mentors to maximize total compatibility using state transition dynamic programming with bitmask optim…
Delete Duplicate Folders in System
Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…
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…
Count Number of Special Subsequences
Learn to count all valid special subsequences in an array using state transition dynamic programming efficiently and cor…
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.
Minimum Total Space Wasted With K Resizing Operations
Find the minimum total space wasted in a dynamic array with at most k resizing operations.
Check If String Is a Prefix of Array
Determine if a string is a prefix of an array by concatenating initial elements, using two-pointer scanning efficiently.
Remove Stones to Minimize the Total
Minimize the total stones by repeatedly removing half from the largest pile using a greedy heap strategy.
Find the Longest Valid Obstacle Course at Each Position
Compute the longest valid obstacle course at each position using binary search and careful array tracking techniques eff…
Number of Strings That Appear as Substrings in Word
Count how many strings in an array appear as substrings within a given word by checking each pattern individually.
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.
Last Day Where You Can Still Cross
Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.
Maximum Matrix Sum
Maximize the sum of an n x n integer matrix using row and column negation operations efficiently with a greedy approach.
Find Greatest Common Divisor of Array
Find the greatest common divisor of the smallest and largest numbers in an integer array.
Find Unique Binary String
Find a binary string of length n not in the input array using array scanning and hash lookup efficiently.
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…
Find Array Given Subset Sums
Reconstruct an array from given subset sums using divide and conquer approach and leveraging array properties.
Minimum Difference Between Highest and Lowest of K Scores
Minimize the difference between the highest and lowest of k student scores using a sliding window approach.
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…
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.
Find the Middle Index in Array
Find the smallest middle index where the sum of elements on the left equals the sum on the right using prefix sums effic…
Find All Groups of Farmland
Identify all rectangular farmland groups in a binary matrix using array traversal and depth-first search efficiently.
Operations on Tree
Design a tree data structure that allows locking, unlocking, and upgrading nodes with user-specific actions.
The Number of Good Subsets
Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.
Count Special Quadruplets
Count Special Quadruplets requires scanning arrays and using hash lookups to efficiently find quadruplets matching sum c…
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…
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.
GCD Sort of an Array
The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.
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.
Count Number of Pairs With Absolute Difference K
Find how many pairs (i, j) with i < j satisfy |nums[i] - nums[j]| == k using array scanning and hash lookup.
Find Original Array From Doubled Array
Given a shuffled array, determine if it is a doubled array and find the original array.
Maximum Earnings From Taxi
Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.
Minimum Number of Operations to Make Array Continuous
Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…
Final Value of Variable After Performing Operations
Compute the final value of X by simulating each string operation in the array sequentially with careful tracking.
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…
Detect Squares
Detect Squares requires tracking points on a 2D plane to quickly count all possible axis-aligned squares using efficient…
Maximum Difference Between Increasing Elements
Find the maximum difference between two increasing elements in an array using a linear scan to track the minimum value e…
Grid Game
Solve the Grid Game problem by optimizing the movement of two robots on a 2D matrix grid.
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 …
The Score of Students Solving Math Expression
Calculate student scores for a single-digit math expression using state transition dynamic programming to track all vali…
Convert 1D Array Into 2D Array
Convert a 1D integer array into a structured 2D array with specified rows and columns using all elements sequentially.
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…
Maximum Number of Ways to Partition an Array
Determine the maximum number of ways to split an array into equal sums using at most one element change, leveraging pref…
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…
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…
Two Out of Three
Identify all elements appearing in at least two of three arrays using efficient scanning and hash lookups for fast verif…
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.
Partition Array Into Two Arrays to Minimize Sum Difference
Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…
Minimum Number of Moves to Seat Everyone
Calculate the minimum total moves to seat each student using greedy assignment and invariant validation efficiently.
The Time When the Network Becomes Idle
Calculate the time when the network becomes idle, factoring in message resending and the BFS traversal method.
Kth Smallest Product of Two Sorted Arrays
Find the kth smallest product from two sorted arrays using binary search across possible product values efficiently.
Simple Bank System
Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…
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…
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.
Parallel Courses III
Solve Parallel Courses III by finding the minimum number of months to complete all courses using graph-based topological…
Kth Distinct String in an Array
Find the kth distinct string in an array by identifying strings that appear only once, using efficient array scanning an…
Two Best Non-Overlapping Events
Maximize the total value of at most two non-overlapping events using state transition dynamic programming efficiently.
Plates Between Candles
Determine the number of plates between candles in a given substring using binary search and prefix sum techniques.
Number of Valid Move Combinations On Chessboard
Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…
Smallest Index With Equal Value
Find the smallest index where the index mod 10 equals the value at that index in the given array.
Minimum Operations to Convert Number
Determine the minimum operations needed to convert a number using array elements with addition, subtraction, or XOR oper…
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.
Maximum Path Quality of a Graph
Calculate the maximum path quality in a graph using backtracking and pruning to optimize node visits within time limits …
Most Beautiful Item for Each Query
Determine the maximum beauty of items affordable for each query using efficient binary search and sorting techniques.
Maximum Number of Tasks You Can Assign
Maximize the number of tasks that can be completed by efficiently using workers and magical pills.
Time Needed to Buy Tickets
Calculate the total time for a specific person to buy all their tickets using queue-driven state processing.
Two Furthest Houses With Different Colors
Maximize the distance between two houses with different colors by using a greedy approach and validating the choice.
Watering Plants
Simulate watering plants while managing a watering can's capacity, considering distance and refills.
Range Frequency Queries
Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…
Count Common Words With One Occurrence
Learn how to efficiently count strings appearing exactly once in both arrays using array scanning and hash lookup patter…
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.
Count Fertile Pyramids in a Land
Solve Count Fertile Pyramids in a Land with matrix DP that measures the tallest pyramid rooted at each fertile cell.
Find Target Indices After Sorting Array
Find the target indices of a sorted array and return them in increasing order using binary search and sorting techniques…
K Radius Subarray Averages
Efficiently calculate the k-radius average for subarrays using sliding window technique.
Removing Minimum and Maximum From Array
The problem asks to remove the minimum and maximum elements from an array with the fewest deletions.
Finding 3-Digit Even Numbers
Generate unique 3-digit even numbers from a given array of digits with duplicates.
Find Subsequence of Length K With the Largest Sum
Pick the k largest values, then restore their original order to build the maximum-sum subsequence correctly.
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…
Detonate the Maximum Bombs
Determine the maximum number of bombs that can be detonated by leveraging chain reactions using graph traversal and DFS …
Sum of Subarray Ranges
Compute the total sum of ranges for all contiguous subarrays efficiently using stack-based state management techniques.
Watering Plants II
Simulate watering a row of plants with Alice and Bob using two-pointer scanning, tracking refills precisely for each ste…
Maximum Fruits Harvested After at Most K Steps
Compute the maximum fruits collectable on an infinite line by moving at most k steps from a start position efficiently.
Find First Palindromic String in the Array
Return the first palindromic string from an array of words or an empty string if none exists.
Adding Spaces to a String
Learn to efficiently insert spaces in a string using two-pointer scanning with invariant tracking in linear time.
Number of Smooth Descent Periods of a Stock
Count all contiguous periods where stock prices descend smoothly by exactly one using dynamic programming techniques.
Minimum Operations to Make the Array K-Increasing
This problem requires finding the minimum number of operations to make an array K-increasing using binary search over th…
Maximum Number of Words Found in Sentences
Find the maximum number of words in a single sentence from an array of sentences using array and string processing techn…
Find All Possible Recipes from Given Supplies
Determine all recipes you can prepare given initial supplies and ingredient dependencies, leveraging array scanning and …
Intervals Between Identical Elements
Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.
Recover the Original Array
Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…
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…
Destroying Asteroids
This problem requires destroying asteroids by choosing the right order of collisions based on mass, using a greedy appro…
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…
Stamping the Grid
Determine if a binary grid can be fully covered using fixed-size stamps by applying a greedy placement and validation st…
Check if Every Row and Column Contains All Numbers
Determine if every row and column in a square matrix contains all numbers from 1 to n without repetition using array sca…
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.
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 …
Earliest Possible Day of Full Bloom
Find the earliest day where all flower seeds are blooming based on their planting and growth times, using a greedy strat…
Solving Questions With Brainpower
Maximize points in an exam with state transition dynamic programming by deciding whether to solve or skip each question.
Maximum Running Time of N Computers
Solve the problem of determining the maximum running time of n computers using a set of batteries.
Minimum Cost of Buying Candies With Discount
Minimize the total cost of buying candies using a greedy approach with a discount system based on candy prices.
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…
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.
Count Elements With Strictly Smaller and Greater Elements
Count elements in an array that have both strictly smaller and strictly greater numbers using array sorting efficiently.
Rearrange Array Elements by Sign
Rearrange an array by alternating positive and negative integers using a two-pointer approach with invariant tracking.
Find All Lonely Numbers in the Array
Find lonely numbers in an array where each lonely number appears once and has no adjacent values.
Maximum Good People Based on Statements
Determine the maximum number of good people in a group given mutual statements, using precise backtracking with pruning.
Keep Multiplying Found Values by Two
The "Keep Multiplying Found Values by Two" problem involves repeatedly multiplying a number by two if it is found in an …
All Divisions With the Highest Score of a Binary Array
Find all indices in a binary array where division score is maximized.
Partition Array According to Given Pivot
Rearrange an array around a pivot while maintaining relative order using a two-pointer scanning approach efficiently.
Minimum Difference in Sums After Removal of Elements
Minimize the difference between sums after removing n elements from a 3n array by dividing the remaining elements into t…
Sort Even and Odd Indices Independently
Rearrange a 0-indexed array by sorting even and odd indices independently for predictable order and correctness.
Design Bitset
Master the Design Bitset problem by efficiently managing bit flips, counts, and indexed updates with array and hash look…
Minimum Operations to Make the Array Alternating
Given an array, calculate the minimum number of operations needed to make it alternating.
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.
Maximum AND Sum of Array
Find the maximum AND sum by placing integers into limited slots using state transition dynamic programming efficiently.
Count Equal and Divisible Pairs in an Array
Given an array, count pairs of elements that are equal and their indices product is divisible by a given integer.
Count Good Triplets in an Array
Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.
Count Array Pairs Divisible by K
Count Array Pairs Divisible by K requires counting index pairs whose products are divisible by a given number k.
Counting Words With a Given Prefix
Count how many words in a list start with a given prefix.
Minimum Time to Complete Trips
Find the minimum time required for buses to complete at least totalTrips using binary search over time multiples.
Minimum Time to Finish the Race
Minimize the time to complete a race with tire swaps using dynamic programming and state transitions.
Most Frequent Number Following Key In an Array
Scan the array once, count which value appears right after the key, and return the uniquely most frequent follower.
Sort the Jumbled Numbers
Sort numbers based on a custom mapping of their digits, leveraging array manipulation and sorting techniques.
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.
Create Binary Tree From Descriptions
Build a binary tree from descriptions of parent-child relationships using array scanning and hash lookup.
Replace Non-Coprime Numbers in Array
Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…
Find All K-Distant Indices in an Array
Identify all indices in an array that are within k distance of elements equal to the given key using two-pointer scannin…
Count Artifacts That Can Be Extracted
Count the number of artifacts that can be extracted after excavating specified grid cells.
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.
Divide Array Into Equal Pairs
Determine if an array of 2n integers can be partitioned into n pairs where each pair contains identical elements using h…
Minimum Operations to Halve Array Sum
Minimize operations to halve an array's sum using greedy choices and heap data structures.
Count Hills and Valleys in an Array
Count Hills and Valleys in an Array determines the number of hills and valleys in a given array by analyzing index neigh…
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…
Longest Substring of One Repeating Character
Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…
Find the Difference of Two Arrays
Find the Difference of Two Arrays helps you identify unique elements between two integer arrays using array scanning and…
Minimum Deletions to Make Array Beautiful
Determine the minimum deletions required to transform an array into a beautiful sequence using stack-based state managem…
Find Palindrome With Fixed Length
Find the smallest palindromes of a given length for specific queries with mathematical and array manipulation.
Maximum Value of K Coins From Piles
Optimize coin selection across multiple piles using state transition dynamic programming to achieve the maximum wallet v…
Find Triangular Sum of an Array
The problem asks for calculating the triangular sum of an array through repeated pairwise summation.
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…
Maximum Candies Allocated to K Children
Maximize candies allocation for k children by dividing piles into sub-piles using binary search.
Encrypt and Decrypt Strings
The 'Encrypt and Decrypt Strings' problem involves creating a data structure that can encrypt and decrypt strings using …
Maximum Product After K Increments
Maximize the product of an array after performing up to k increments using a greedy approach with heap optimization.
Maximum Total Beauty of the Gardens
Determine the maximum total beauty of gardens by strategically planting flowers using binary search over achievable flow…
Find Closest Number to Zero
Identify the number in an integer array that is closest to zero, returning the larger one if tied.
Design an ATM Machine
Design an ATM machine that stores and withdraws money with given denominations and prioritizes larger values during with…
Maximum Score of a Node Sequence
Find the maximum score of a valid node sequence in an undirected graph with given node scores and edges.
Minimum Rounds to Complete All Tasks
The problem requires finding the minimum rounds to complete tasks, focusing on greedy algorithms and hash table lookups.
Maximum Trailing Zeros in a Cornered Path
Find the maximum trailing zeros in the product of a cornered path within a 2D grid.
Longest Path With Different Adjacent Characters
Find the longest path in a tree where adjacent nodes have different characters using graph DFS and topological reasoning…
Intersection of Multiple Arrays
Find integers that are common across all arrays in a given list of arrays.
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.
Count Number of Rectangles Containing Each Point
Given a set of rectangles and points, determine how many rectangles contain each point.
Number of Flowers in Full Bloom
Find the number of flowers in full bloom at the given times for a list of people.
Count Prefixes of a Given String
Count Prefixes of a Given String is a problem that involves finding the number of string prefixes in an array that match…
Minimum Average Difference
Find the index with the minimum average difference in an array using prefix sums.
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…
Escape the Spreading Fire
Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…
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 …
K Divisible Elements Subarrays
Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…
Check if There Is a Valid Parentheses String Path
Check if there exists a valid parentheses string path in a given grid using state transition dynamic programming.
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…
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…
Substring With Largest Variance
Find the largest variance possible in any substring of a given string using dynamic programming.
Find Resultant Array After Removing Anagrams
This problem requires removing adjacent anagrams from a list of words using an array scanning and hash lookup approach.
Maximum Consecutive Floors Without Special Floors
Find the maximum sequence of consecutive floors without any special floors using array sorting techniques efficiently.
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…
Maximum Bags With Full Capacity of Rocks
Maximize the number of bags filled to capacity by distributing additional rocks using a greedy approach.
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…
Sum of Total Strength of Wizards
The Sum of Total Strength of Wizards problem asks for the sum of the total strengths of all contiguous subarrays of wiza…
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…
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…
Minimum Obstacle Removal to Reach Corner
Find the minimum obstacles to remove in a 2D grid to reach the bottom-right corner using BFS graph traversal techniques.
Min Max Game
The Min Max Game problem requires simulating an array reduction process to find the last remaining number.
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 …
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 …
Successful Pairs of Spells and Potions
Count how many potions pair successfully with each spell using binary search over sorted potion strengths efficiently.
Match Substring After Replacement
Determine if a target substring can appear in a string after optional character replacements using given mappings effici…
Count Subarrays With Score Less Than K
Count all non-empty subarrays whose score, defined as sum times length, is strictly less than a given integer k efficien…
Calculate Amount Paid in Taxes
Calculate the total tax owed by iterating through sorted brackets and applying each rate incrementally to your income.
Minimum Path Cost in a Grid
Minimize the cost of a path in a grid while considering move costs for each step.
Fair Distribution of Cookies
The problem focuses on fairly distributing cookies among children to minimize the maximum unfairness of the distribution…
Naming a Company
The "Naming a Company" problem requires determining the number of valid distinct company names from a list of name ideas…
Selling Pieces of Wood
Maximize your profit by cutting a wooden piece into smaller parts based on given prices and dimensions.
Maximum XOR After Operations
Maximize the bitwise XOR of an array after applying a special operation with non-negative integers multiple times.
Check if Matrix Is X-Matrix
Check if a square matrix follows the X-Matrix pattern by validating diagonal and non-diagonal conditions.
Maximum Score Of Spliced Array
Maximize the score of two arrays by splicing and swapping a subarray using dynamic programming.
Minimum Score After Removals on a Tree
Compute the minimum score after removing two edges in a tree using DFS and XOR-based component tracking efficiently.
Spiral Matrix IV
In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.
Number of Increasing Paths in a Grid
Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…
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 …
Minimum Sum of Squared Difference
Calculate the minimum sum of squared differences between two arrays using limited modifications and binary search techni…
Subarray With Elements Greater Than Varying Threshold
Find the size of a subarray with all elements greater than threshold divided by length using stack-based state managemen…
Minimum Amount of Time to Fill Cups
Determine the minimum seconds to fill cups of cold, warm, and hot water using a greedy selection strategy and invariant …
Maximum Number of Pairs in Array
Given an array, count how many pairs can be formed and how many leftovers remain after pairing.
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.
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…
Minimum Deletions to Make Array Divisible
Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.
Best Poker Hand
Determine the strongest poker hand from five cards using array scanning and hash table counting techniques efficiently.
Number of Zero-Filled Subarrays
Given an array of integers, count the subarrays that consist entirely of 0s.
Shortest Impossible Sequence of Rolls
Find the shortest subsequence that cannot be formed from a sequence of dice rolls, with efficient array scanning and has…
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…
Design a Food Rating System
Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.
Number of Excellent Pairs
Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…
Make Array Zero by Subtracting Equal Amounts
Minimize operations to make all array elements zero by subtracting equal amounts in each operation.
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…
Merge Similar Items
Merge Similar Items combines values and weights from two lists, returning the result sorted by value.
Count Number of Bad Pairs
Count the number of bad pairs in an array where the difference between indices and values does not match.
Task Scheduler II
Complete tasks in the optimal number of days by considering breaks and task type constraints.
Minimum Replacements to Sort the Array
Minimize the number of operations to make the array sorted in non-decreasing order by replacing elements with sums of tw…
Number of Arithmetic Triplets
Count the number of arithmetic triplets in a given strictly increasing array with a specified difference.
Reachable Nodes With Restrictions
In the 'Reachable Nodes With Restrictions' problem, find the maximum reachable nodes from node 0 in a tree while avoidin…
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.
Largest Local Values in a Matrix
Find the largest value in every 3x3 submatrix of an n x n integer matrix efficiently using nested loops.
Shifting Letters II
Shift letters in a string using a sequence of range-based forward or backward operations efficiently with prefix sums.
Maximum Segment Sum After Removals
Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…
Minimum Hours of Training to Win a Competition
Find the minimum hours of training needed to beat all opponents in a competition based on energy and experience.
Find the K-Sum of an Array
Find the K-Sum of an Array requires computing the kth largest subsequence sum in an array using sorting and heap techniq…
Longest Subsequence With Limited Sum
Find the maximum size of a subsequence from nums with a sum less than or equal to each query value.
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 …
Build a Matrix With Conditions
Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…
Find Subarrays With Equal Sum
Find Subarrays With Equal Sum is solved by scanning adjacent pairs and storing each length-2 sum in a hash set.
Maximum Rows Covered by Columns
Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…
Maximum Number of Robots Within Budget
Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…
Check Distances Between Same Letters
Verify if each pair of identical letters in a string has the exact number of letters between them as specified in a dist…
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.
Meeting Rooms III
Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.
Most Frequent Even Element
Identify the most frequent even element in an array using counting and hash lookup, handling ties by choosing the smalle…
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.
Longest Increasing Subsequence II
Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…
Maximum Matching of Players With Trainers
Maximize the number of valid player-trainer matchings using two-pointer scanning and careful sorting strategy.
Smallest Subarrays With Maximum Bitwise OR
Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.
Minimum Money Required Before Transactions
Find the minimum money required to complete all transactions in any order while considering cost and cashback.
Sum of Prefix Scores of Strings
The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …
Sort the People
Sort the People requires pairing names with heights and sorting them in descending height order efficiently using arrays…
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…
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.
Number of Good Paths
Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.
Bitwise XOR of All Pairings
Compute the overall bitwise XOR from all pairings between two arrays using efficient array and bit manipulation techniqu…
Number of Pairs Satisfying Inequality
Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.
Maximum Sum of an Hourglass
Calculate the maximum sum of an hourglass in a 2D matrix using array traversal and submatrix evaluation techniques effic…
The Employee That Worked on the Longest Task
Identify which employee spent the longest time on a task using an array-driven approach, analyzing each log entry effici…
Find The Original Array of Prefix Xor
Find the original array from a given prefix XOR array using bitwise manipulation techniques.
Paths in Matrix Whose Sum Is Divisible by K
Compute all paths in a matrix where the sum of elements is divisible by k using state transition dynamic programming eff…
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 …
Minimize Maximum of Array
Minimize Maximum of Array involves finding the smallest possible maximum value after applying a series of operations on …
Create Components With Same Value
Maximize the number of components in a tree with equal sums by carefully deleting edges using divisor-based logic.
Largest Positive Integer That Exists With Its Negative
Find the largest positive integer in an array such that its negative counterpart also exists.
Count Number of Distinct Integers After Reverse Operations
This problem requires counting distinct integers after performing reverse operations on each integer in an array.
Count Subarrays With Fixed Bounds
Count all subarrays where the minimum and maximum match given bounds using efficient sliding window tracking techniques.
Determine if Two Events Have Conflict
Compare two same-day time intervals and check whether their inclusive endpoints overlap after converting HH:MM strings i…
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.
Minimum Cost to Make Array Equal
Find the minimum cost to make all elements of an array equal by using binary search over valid answers.
Minimum Number of Operations to Make Arrays Similar
Determine the minimum operations to make two arrays similar by adjusting pairs while respecting element frequencies and …
Odd String Difference
Identify the one string in an array whose consecutive letter differences deviate from all others using array scanning pl…
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…
Destroy Sequential Targets
Find the minimum seed value to destroy the most targets on a number line, using array scanning and hash lookup.
Next Greater Element IV
Find the second greater integer for each element in an array using binary search and monotonic stack techniques.
Average Value of Even Numbers That Are Divisible by Three
Find the average of even numbers divisible by 3 from an array of positive integers.
Most Popular Video Creator
Identify the most popular video creator by summing views and selecting their top-viewed video with array and hash patter…
Height of Binary Tree After Subtree Removal Queries
Compute the height of a binary tree efficiently after removing subtrees, using traversal and precomputed node state trac…
Apply Operations to an Array
Transform an array by applying adjacent doubling operations and shifting zeros efficiently using two-pointer scanning te…
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.
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…
Minimum Total Distance Traveled
Optimize the total distance traveled by robots to factories using dynamic programming, sorting, and state transitions.
Number of Distinct Averages
Calculate the number of unique averages formed by repeatedly pairing smallest and largest elements efficiently using has…
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…
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.
Number of Unequal Triplets in Array
Count all triplets in a positive integer array where each element is distinct using scanning and hash lookup efficiently…
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…
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…
Count Subarrays With Median K
Count the number of subarrays in a given array with median equal to a specified value k.
Divide Players Into Teams of Equal Skill
Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.
Maximum Value of a String in an Array
The problem requires finding the maximum value of alphanumeric strings in an array based on length or numeric value.
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 …
Frog Jump II
Frog Jump II requires finding the minimal maximum jump length for a frog to traverse stones forward and backward efficie…
Minimum Total Cost to Make Arrays Unequal
Calculate the minimum cost to rearrange nums1 so that no element matches nums2 using optimal swaps and hash counting.
Delete Greatest Value in Each Row
Calculate the total of removed maximum values from each row of a matrix, iterating until all columns are deleted efficie…
Longest Square Streak in an Array
Find the length of the longest subsequence where each element is a perfect square of its previous one.
Design Memory Allocator
Design a memory allocator that simulates allocation and deallocation of memory blocks.
Maximum Number of Points From Grid Queries
Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.
Count Pairs Of Similar Strings
Count similar string pairs by converting each word into a character-set signature and counting matching signatures effic…
Cycle Length Queries in a Tree
Solve the problem of determining cycle lengths in a binary tree with added edges through queries.
Maximum Enemy Forts That Can Be Captured
Find the maximum number of enemy forts that can be captured by moving your army using two-pointer scanning with invarian…
Reward Top K Students
Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…
Shortest Distance to Target String in a Circular Array
Find the shortest distance to a target string in a circular array with either left or right movement options.
Maximum Tastiness of Candy Basket
Maximize the tastiness of a candy basket by choosing k candies from a list of candy prices.
Number of Great Partitions
Calculate the number of great partitions of an array using state transition dynamic programming with careful sum constra…
Distinct Prime Factors of Product of Array
Find the number of distinct prime factors in the product of an array of integers.
Find Xor-Beauty of Array
Find the xor-beauty of an array by XORing the effective values of all possible triplets of indices.
Maximize the Minimum Powered City
Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…
Maximum Count of Positive Integer and Negative Integer
Compute the maximum count between positive and negative integers in a sorted array using efficient binary search countin…
Maximal Score After Applying K Operations
Maximize your score by applying exactly k operations on an array using greedy selection and heap optimization techniques…
Time to Cross a Bridge
Time to Cross a Bridge involves simulating worker movements using arrays and heaps to determine when the last worker cro…
Difference Between Element Sum and Digit Sum of an Array
Find the absolute difference between element sum and digit sum of an array of integers.
Increment Submatrices by One
Increment Submatrices by One focuses on efficiently updating submatrices using row-wise prefix sums in an n by n matrix.
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.
Difference Between Maximum and Minimum Price Sum
Compute the maximum difference between any path price sum in a tree using binary-tree traversal and state tracking effic…
Minimum Common Value
Find the smallest integer appearing in both sorted arrays efficiently using array scanning and hash-based lookup techniq…
Minimum Operations to Make Array Equal II
Calculate the minimum operations to make two integer arrays equal using greedy adjustments with modular checks efficient…
Maximum Subsequence Score
Maximize the score of a subsequence by selecting indices based on nums1 and nums2, using a greedy approach and sorting.
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.
Minimum Cost to Split an Array
Minimize the cost of splitting an array into k subarrays by calculating importance values and applying dynamic programmi…
Count Distinct Numbers on Board
Compute the number of distinct integers generated on a board using repeated modulo operations over a long sequence of da…
Put Marbles in Bags
The "Put Marbles in Bags" problem challenges you to distribute marbles into bags for maximum score difference using gree…
Count Increasing Quadruplets
Given a permutation of numbers, count the number of increasing quadruplets using dynamic programming.
Separate the Digits in an Array
Given an array of positive integers, separate each integer into its individual digits while preserving the original orde…
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.
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…
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…
Take Gifts From the Richest Pile
Take Gifts From the Richest Pile uses a heap to simulate the process of taking gifts from the richest pile over a number…
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.
House Robber IV
House Robber IV requires calculating minimum maximum money the robber can take using state transition dynamic programmin…
Rearranging Fruits
Solve the problem of rearranging fruit baskets by comparing fruit costs and minimizing swaps using array scanning and ha…
Find the Array Concatenation Value
Compute the array concatenation value efficiently using two-pointer scanning while maintaining a running total of concat…
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…
Substring XOR Queries
Solve the Substring XOR Queries problem using array scanning and hash lookup to efficiently handle multiple queries on b…
Minimum Score by Changing Two Elements
The problem asks for the minimum score after changing two elements of an array using a greedy approach.
Minimum Impossible OR
Find the smallest positive integer that cannot be formed from any subsequence OR combination in the array.
Handling Sum Queries After Update
Solve the Handling Sum Queries After Update problem using arrays and segment trees with lazy propagation for efficiency.
Merge Two 2D Arrays by Summing Values
Merge two 2D arrays by summing values with matching ids using array scanning and hash lookup efficiently.
Count the Number of Square-Free Subsets
Learn how to efficiently count square-free subsets using state transition dynamic programming with bitmask optimizations…
Find the String with LCP
Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.
Left and Right Sum Differences
Compute absolute differences between left and right cumulative sums for each element in an integer array efficiently.
Find the Divisibility Array of a String
Calculate the divisibility array for a string by checking if prefixes are divisible by a given number.
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…
Minimum Time to Visit a Cell In a Grid
Compute the fastest path in a grid where each cell has a minimum time requirement using BFS and priority queue technique…
Count Ways to Group Overlapping Ranges
Count Ways to Group Overlapping Ranges is a medium difficulty problem focused on array manipulation and sorting to count…
Count Number of Possible Root Nodes
Given a tree and a set of guesses, find how many nodes can be the root while satisfying the guess constraints.
Split the Array to Make Coprime Products
Find the smallest index to split an array so that the products of two parts are coprime using array scanning and hash lo…
Number of Ways to Earn Points
Find the number of ways to earn exactly target points using multiple types of exam questions with distinct marks.
Count the Number of Vowel Strings in Range
Count the Number of Vowel Strings in Range asks to count vowel strings in a subarray of a given word list.
Rearrange Array to Maximize Prefix Score
Maximize the number of positive prefix sums by rearranging an integer array using a greedy, order-focused strategy.
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…
Minimum Time to Complete All Tasks
Determine the minimum active time for a computer to complete all scheduled tasks within their specific time windows effi…
Maximize Greatness of an Array
Maximize Greatness of an Array requires permuting numbers to exceed original values at most indices efficiently.
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.
Minimum Time to Repair Cars
Find the minimum time to repair all cars using mechanics with different ranks, applying binary search over possible time…
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.
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…
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…
Prime Subtraction Operation
Determine if it's possible to make the array strictly increasing using prime subtractions.
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.
Collect Coins in a Tree
The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…
Form Smallest Number From Two Digit Arrays
Given two arrays of digits, find the smallest possible number formed by one digit from each array.
Find the Substring With Maximum Cost
Find the Substring With Maximum Cost requires calculating substring values using a hash lookup for character costs, with…
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.
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…
Mice and Cheese
In 'Mice and Cheese', you must maximize the total reward of two mice eating cheese while respecting their preferences an…
Minimum Reverse Operations
Find the minimum number of operations to move a 1 in an array from a given start position to other positions, considerin…
Prime In Diagonal
Find the largest prime number located on any diagonal of a square matrix using array iteration and prime checking techni…
Sum of Distances
In this problem, you calculate an array where each element is the sum of absolute differences of indices for equal value…
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 …
Minimum Number of Visited Cells in a Grid
Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…
Find the Width of Columns of a Grid
This problem asks you to compute the width of each column in a grid, where the width is defined by the length of the lar…
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…
Row With Maximum Ones
Find the row with the maximum ones in a binary matrix and return its index and count.
Find the Maximum Divisibility Score
Determine the divisor with the highest count of divisible elements in an array using a clear array-driven strategy.
Minimize the Total Price of the Trips
Calculate the minimum total cost of multiple trips on a tree by selectively halving node prices using DFS frequency coun…
Sliding Subarray Beauty
Compute the xth smallest negative number in each sliding subarray using array scanning and hash frequency tracking effic…
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…
Maximum Sum With Exactly K Elements
Maximize your score by performing exactly k operations on an array using a greedy approach to select the highest values.
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…
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.
Make Array Empty
Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.
Determine the Winner of a Bowling Game
Simulate a bowling game to determine the winner based on hit pins per turn for two players.
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.
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.
Find the Distinct Difference Array
Calculate the distinct difference array of a given list of integers by counting distinct elements in the prefix and suff…
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…
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.
Number of Senior Citizens
Determine how many passengers are over 60 years old based on their compressed details in an array of strings.
Sum in a Matrix
Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…
Maximum OR
Maximize the bitwise OR of an array by applying at most k multiplication operations on selected elements.
Power of Heroes
Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…
Find the Losers of the Circular Game
Simulate a ball-passing game around a circle using array scanning and hash lookup to find friends who never receive the …
Neighboring Bitwise XOR
Determine if a binary array original exists that produces the given derived array using neighboring bitwise XOR logic.
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.
Buy Two Chocolates
Determine the leftover money after buying exactly two chocolates using a greedy selection and sum validation approach.
Extra Characters in a String
The problem asks for the minimum number of extra characters left after optimally breaking a string into substrings found…
Maximum Strength of a Group
Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…
Greatest Common Divisor Traversal
Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.
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.
Maximum Strictly Increasing Cells in a Matrix
Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…
Semi-Ordered Permutation
Find the minimum number of operations to convert a permutation into a semi-ordered permutation where 1 is first and n is…
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…
Movement of Robots
Calculate total distances between robots moving on a number line while accounting for collisions using array plus braint…
Find a Good Subset of the Matrix
Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…
Neither Minimum nor Maximum
Find a number in an array that is neither the minimum nor maximum value, or return -1 if no such number exists.
Collecting Chocolates
Calculate the minimum cost to collect all chocolate types using rotations and purchases in an array-based enumeration pa…
Maximum Sum Queries
Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…
Find the Value of the Partition
Find the minimum partition value by dividing a positive integer array into two subarrays using sorting for efficiency.
Special Permutations
Count the number of special permutations for a given array using dynamic programming and bit manipulation.
Painting the Walls
Compute the minimum cost to paint all walls using a paid and free painter with state transition dynamic programming.
Find Maximum Number of String Pairs
Find the maximum number of pairs of distinct strings from an array where one string is the reverse of the other.
Decremental String Concatenation
Solve the Decremental String Concatenation problem by applying dynamic programming to minimize string length after conca…
Count Zero Request Servers
Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…
Number of Beautiful Pairs
Count all index pairs in an array where the first digit of one number and last digit of another are coprime efficiently.
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 …
Robot Collisions
Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.
Longest Even Odd Subarray With Threshold
Determine the length of the longest subarray where elements alternate even and odd while staying below a given threshold…
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.
Continuous Subarrays
Count all continuous subarrays efficiently using sliding window with running max-min state tracking for array consistenc…
Sum of Imbalance Numbers of All Subarrays
Learn how to compute the total imbalance across all subarrays by updating gap counts as each subarray expands.
Longest Alternating Subarray
Find the longest alternating subarray in a given array of integers.
Relocate Marbles
Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.
Number of Black Blocks
Calculate the number of black blocks in a grid given a list of black cell coordinates.
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…
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…
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.
Sum of Squares of Special Elements
Calculate the sum of squares of special elements in a 1-indexed array using index divisibility checks efficiently.
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…
Minimum Index of a Valid Split
Find the minimum index to split an array such that both subarrays have the same dominant element.
Length of the Longest Valid Substring
This problem asks for the longest valid substring of a word that doesn't contain any substrings from a forbidden list.
Check if Array is Good
Determine if a given integer array is a permutation of base[n], containing 1 to n-1 once and n twice, using scanning and…
Visit Array Positions to Maximize Score
Maximize your score by visiting positions in an array while handling penalties for parity changes efficiently with DP.
Split Strings by Separator
Split Strings by Separator requires iterating through an array of strings and splitting each by a given separator charac…
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.
Maximum Number of Groups With Increasing Length
Maximize the number of groups that can be formed with given usage limits, leveraging binary search for optimal solutions…
Number of Employees Who Met the Target
Determine how many employees reach the required work hours using a direct array-driven counting approach.
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…
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.
Minimum Time to Make Array Sum At Most x
Calculate the minimum seconds to reduce the array sum to at most x using optimal single-time reductions per index effici…
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…
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.
Maximum Elegance of a K-Length Subsequence
Maximize elegance of a k-length subsequence from a list of items with profits and categories.
Max Pair Sum in an Array
Find the maximum sum of two numbers in an array sharing the same largest digit using a hash-based scan efficiently.
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.
Apply Operations to Maximize Score
Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.
Count Pairs Whose Sum is Less than Target
This problem asks you to count all index pairs in an array whose sum is strictly less than a given target value efficien…
Sorting Three Groups
Determine the minimum removals to make an array of 1s, 2s, and 3s non-decreasing using dynamic programming transitions.
Check if a String Is an Acronym of Words
Check if a string can be formed by concatenating the first letters of each word in a given list.
Maximize the Profit as the Salesman
Determine the maximum profit a salesman can earn by strategically selecting non-overlapping offers on consecutive houses…
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…
Minimum Operations to Form Subsequence With Target Sum
The problem requires finding the minimum number of operations to form a subsequence summing to a target using powers of …
Maximize Value of Function in a Ball Passing Game
Maximize the total score in a ball-passing game by selecting the best starting player using state transition dynamic pro…
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…
Count of Interesting Subarrays
Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …
Minimum Edge Weight Equilibrium Queries in a Tree
Find the minimum number of operations to equalize edge weights in a tree between given pairs of nodes.
Points That Intersect With Cars
Count covered integer points by merging overlapping car intervals or marking visited positions on the number line.
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…
Minimum Right Shifts to Sort the Array
Determine the minimum number of right shifts to sort a distinct integer array or return -1 if impossible using array ana…
Minimum Array Length After Pair Removals
This problem involves minimizing the length of a sorted array by repeatedly removing adjacent pairs of equal elements.
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.
Sum of Values at Indices With K Set Bits
Sum values in an array where the indices have exactly k set bits in binary representation.
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…
Maximum Number of Alloys
Determine the maximum number of alloys possible using limited metal stock and budget, leveraging binary search efficient…
Maximum Element-Sum of a Complete Subset of Indices
Given a 1-indexed array, select a subset where indices' product is a perfect square, then return the maximum sum.
Beautiful Towers I
Solve Beautiful Towers I by testing each peak and enforcing mountain limits with monotonic stack style height propagatio…
Beautiful Towers II
Maximize tower configurations with the stack-based approach while ensuring mountain-like patterns in this medium difficu…
Minimum Operations to Collect Elements
Scan from the end, track seen values from 1 to k, and stop once every required number is collected.
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.
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…
Maximum Value of an Ordered Triplet I
Find the maximum value of a triplet in an array where indices follow the order i < j < k.
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.
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.
Minimum Processing Time
Determine the minimum total processing time by optimally assigning tasks to multiple processors using a greedy approach.
Apply Operations on Array to Maximize Sum of Squares
Maximizing the sum of squares in an array through bitwise operations on selected elements.
Last Visited Integers
This problem involves finding the last visited integer for each -1 in a given array by simulating a stack-like behavior.
Longest Unequal Adjacent Groups Subsequence I
Find the longest alternating subsequence in a string array based on a binary group array.
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…
Count of Sub-Multisets With Bounded Sum
This problem asks you to count the number of sub-multisets within a given array that have a sum in a specified range.
Find Indices With Index and Value Difference I
Find two indices in an array where their difference in both index and value meets specified thresholds.
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…
Construct Product Matrix
Solve the "Construct Product Matrix" problem by calculating the product of elements in 2D matrices without division.
Minimum Sum of Mountain Triplets I
Find the minimum sum of a mountain triplet in an array of integers, or return -1 if no valid triplet exists.
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.
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.
Subarrays Distinct Element Sum of Squares I
Compute the sum of squares of distinct elements for all subarrays using array scanning with hash lookups efficiently.
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.
Subarrays Distinct Element Sum of Squares II
Compute the sum of squares of distinct elements in all subarrays using state transition dynamic programming efficiently.
Find the K-or of an Array
Given an integer array nums and an integer k, find the K-or of nums where bits qualify based on the occurrence of 1s.
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…
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 …
Maximum Points After Collecting Coins From All Nodes
Find the maximum points after collecting coins from all nodes of a tree using binary-tree traversal and state tracking.
Find Champion I
Find Champion I is an easy problem focusing on identifying the strongest team in a tournament using matrix-based compari…
Maximum Balanced Subsequence Sum
Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…
Maximum Spending After Buying Items
Maximize spending by carefully choosing the right items across multiple shops over m * n days.
Maximum Strong Pair XOR I
Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.
High-Access Employees
Identify employees with high system access within one-hour periods based on access logs.
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.
Maximum Strong Pair XOR II
Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.
Find Building Where Alice and Bob Can Meet
Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.
Find Words Containing Character
Identify all indices of words containing a specific character using array and string traversal techniques efficiently.
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 …
Minimum Number of Coins for Fruits
Calculate the minimum coins to buy fruits using state transition dynamic programming while handling rewards and purchase…
Find Maximum Non-decreasing Array Length
Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…
Matrix Similarity After Cyclic Shifts
Determine if a matrix returns to its original state after performing cyclic row shifts k times using array and math patt…
Make Lexicographically Smallest Array by Swapping Elements
Solve the problem of making an array lexicographically smallest through element swaps under a limit constraint.
Find the Peaks
Identify all peaks in a mountain array using direct array enumeration and strict neighbor comparisons efficiently.
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.
Count the Number of Infection Sequences
Calculate all valid infection sequences in a line by using array positions and combinatorial math efficiently for n peop…
Find Common Elements Between Two Arrays
Quickly find all numbers that appear in both arrays using scanning and hash lookup to handle duplicates efficiently.
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.
Count Tested Devices After Test Operations
Simulate testing devices based on battery percentages to determine how many pass the test operations in sequence.
Double Modular Exponentiation
Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…
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.
Count the Number of Good Partitions
Calculate how many ways to partition an array into contiguous subarrays where no number repeats across segments using ha…
Find Missing and Repeated Values
Find the missing and repeated numbers in an n x n grid using array scanning and hash lookup.
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.
Minimum Cost to Make Array Equalindromic
Determine the minimum cost to convert an integer array into a palindromic array using allowed element modifications effi…
Apply Operations to Maximize Frequency Score
Maximize the frequency score by applying up to k operations on a sorted array using binary search over valid answer spac…
Count the Number of Incremovable Subarrays I
Count the number of incremovable subarrays in an array by removing them to create a strictly increasing sequence.
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…
Count the Number of Incremovable Subarrays II
Count the number of incremovable subarrays where removal of the subarray results in a strictly increasing array.
Minimum Number Game
The Minimum Number Game involves simulating moves by Alice and Bob on an array, sorting elements and appending them to a…
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…
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…
Minimum Cost to Convert String II
Compute the minimum cost to transform source into target using substring replacements with given costs efficiently using…
Check if Bitwise OR Has Trailing Zeros
Check if a bitwise OR of two or more numbers has trailing zeros in its binary representation.
Smallest Missing Integer Greater Than Sequential Prefix Sum
Find the smallest missing integer greater than the sum of the longest sequential prefix in an array.
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.
Maximum Area of Longest Diagonal Rectangle
Find the rectangle with the longest diagonal in a 2D array and return its area, prioritizing maximum area on ties.
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.
Count Elements With Maximum Frequency
Count Elements With Maximum Frequency is solved by counting each value, tracking the highest count, and summing matching…
Divide an Array Into Subarrays With Minimum Cost I
Divide an array into three contiguous subarrays with minimum cost by leveraging array and sorting principles.
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.
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.
Divide an Array Into Subarrays With Minimum Cost II
This problem asks to divide an array into subarrays with a minimal cost and certain constraints on subarray positions.
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…
Minimize OR of Remaining Elements Using Operations
Minimize the bitwise OR of the remaining elements of an array after applying at most k operations.
Type of Triangle
Determine the type of triangle from a three-element array using side sums and equality checks efficiently in constant ti…
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…
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…
Find the Number of Ways to Place People II
Calculate all valid placements of people on a 2D grid ensuring Alice can fence herself with Bob without enclosing others…
Ant on the Boundary
Solve the problem of counting how often an ant returns to a boundary based on the steps described in the input array.
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, …
Modify the Matrix
Modify the Matrix efficiently by replacing all -1 elements with the maximum in their column using array and matrix opera…
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…
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…
Number of Subarrays That Match a Pattern II
Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.
Maximum Number of Operations With the Same Score I
Determine the maximum number of operations in an integer array where each operation must produce the same score.
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.
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…
Maximize Consecutive Elements in an Array After Modification
Solve Maximize Consecutive Elements in an Array After Modification by sorting and using state transition DP on value and…
Count Prefix and Suffix Pairs I
Count all index pairs where one word is both a prefix and suffix of another, using efficient array and string checks.
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…
Most Frequent Prime
Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…
Count Prefix and Suffix Pairs II
Count the number of index pairs in a string array where one word is both a prefix and suffix of another using array and …
Split the Array
Determine if an even-length array can be split into two parts with all distinct elements using hash lookup scanning.
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.
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.
Earliest Second to Mark Indices II
This problem asks to determine the earliest second at which all indices in an array can be marked using a sequence of op…
Minimum Operations to Exceed Threshold Value I
Count how many numbers are below k, because each such value must be removed in Minimum Operations to Exceed Threshold Va…
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…
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…
Find the Maximum Sum of Node Values
Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…
Distribute Elements Into Two Arrays I
Distribute elements from a distinct integer array into two subarrays using a sequential simulation strategy for optimal …
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.
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.
Distribute Elements Into Two Arrays II
Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…
Apple Redistribution into Boxes
Distribute packs of apples into boxes using a greedy strategy, minimizing the number of boxes selected efficiently and c…
Maximize Happiness of Selected Children
Maximize the happiness of selected children by choosing the k happiest ones and applying greedy strategies to minimize l…
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…
Maximum Strength of K Disjoint Subarrays
Solve Maximum Strength of K Disjoint Subarrays with dynamic programming that tracks segment state, sign changes, and wei…
Find the Sum of Encrypted Integers
Compute the sum of encrypted integers by replacing each digit with the largest digit, combining array traversal with dig…
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…
Find the Sum of the Power of All Subsequences
Find the sum of the power of all subsequences of an integer array where their sum equals a given number.
Minimum Moves to Pick K Ones
Find the minimum number of moves to pick exactly k ones from a binary array, considering a constraint on changes.
Most Frequent IDs
Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.
Longest Common Suffix Queries
Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…
Shortest Subarray With OR at Least K I
Find the shortest non-empty subarray in nums whose bitwise OR reaches at least k using sliding window efficiently.
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…
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.
Find the Sum of Subsequence Powers
Compute the sum of powers for all subsequences of length k using state transition dynamic programming efficiently.
Count Alternating Subarrays
Count all alternating subarrays in a binary array efficiently using array patterns and simple mathematical reasoning.
Minimize Manhattan Distances
Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.
Longest Strictly Increasing or Strictly Decreasing Subarray
Find the longest subarray in a given array that is either strictly increasing or strictly decreasing.
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…
Minimum Cost Walk in Weighted Graph
Find the minimum cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…
Minimum Rectangles to Cover Points
Find the minimum number of rectangles needed to cover all points, given constraints on width and position.
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…
Find the Number of Subarrays Where Boundary Elements Are Maximum
Count the subarrays where the first and last elements are the largest in the subarray, utilizing binary search over vali…
Maximum Prime Difference
Calculate the largest index gap between prime numbers in an array using array traversal and number theory insights effic…
Kth Smallest Amount With Single Denomination Combination
Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…
Minimum Sum of Values by Dividing Array
Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.
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…
Make a Square with the Same Color
Determine if a 3x3 grid can form a 2x2 square of the same color by changing at most one cell efficiently.
Right Triangles
Count all possible right triangles in a 2D boolean grid using array scanning and hash lookup for efficiency.
Find the Integer Added to Array I
Find the integer added to nums1 to make it equal to nums2 using an array-driven strategy.
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…
Find the Median of the Uniqueness Array
Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…
Minimum Cost to Equalize Array
Compute the minimum cost to make all elements equal using selective operations guided by greedy choices and invariant ch…
Check if Grid Satisfies Conditions
Check if a grid satisfies given conditions by analyzing array and matrix structure with specific checks on values.
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.
Find Products of Elements of Big Array
Solve queries on a massive array of powers of two using binary search to efficiently compute modular products of subarra…
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…
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.
Find the Minimum Cost Array Permutation
Determine the lexicographically smallest permutation of nums that minimizes a cyclic score using state transition DP tec…
Special Array I
Determine if an array is special by checking alternating parity for every adjacent pair in linear time.
Special Array II
Determine whether each subarray meets the special condition of alternating parity for all adjacent elements efficiently …
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…
Find the XOR of Numbers Which Appear Twice
Find the XOR of numbers appearing twice by scanning the array and using a hash table for efficient tracking and combinat…
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.
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…
Block Placement Queries
Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…
Find the Number of Good Pairs I
Count all good pairs where an element in nums1 is divisible by a scaled element in nums2 using efficient array scanning.
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.
Maximum Sum of Subsequence With Non-adjacent Elements
Compute the maximum sum of a subsequence where no two adjacent elements are selected after each array update efficiently…
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.
Find Subarray With Bitwise OR Closest to K
Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.
Find The 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…
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.
Find the Maximum Length of a Good Subsequence II
Determine the maximum length of a good subsequence in an integer array using array scanning and hash lookup efficiently.
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.
Maximum Total Reward Using Operations I
Optimize the total reward by choosing operations on array indices using state transition dynamic programming techniques …
Maximum Total Reward Using Operations II
Maximize your total reward using dynamic programming with state transitions in this challenging problem involving array …
Count Pairs That Form a Complete Day I
Count all pairs in an array where their sum forms a complete day using hash-based counting for efficiency.
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.
Maximum Total Damage With Spell Casting
Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…
Peaks in Array
Determine peaks in a dynamic integer array using efficient Binary Indexed Tree updates and range queries for fast result…
Find Minimum Operations to Make All Elements Divisible by Three
Find the minimum number of operations to make all elements in an array divisible by three.
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…
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…
Count the Number of Inversions
Count the number of valid permutations satisfying inversion constraints using state transition dynamic programming.
Minimum Average of Smallest and Largest Elements
Solve the Minimum Average of Smallest and Largest Elements problem using two-pointer scanning to track averages effectiv…
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.
Maximize Total Cost of Alternating Subarrays
Maximize the total cost of alternating subarrays using dynamic programming to efficiently split an array into optimal su…
Find the Minimum Area to Cover All Ones II
Find the minimum area to cover all 1's in a 2D binary grid using three non-overlapping rectangles.
Maximum Height of a Triangle
Find the maximum height of a triangle that can be formed using red and blue balls under given constraints.
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…
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…
Alternating Groups I
Count all alternating groups in a circular array by tracking tiles with distinct neighbors efficiently using sliding win…
Maximum Points After Enemy Battles
Solve the "Maximum Points After Enemy Battles" problem by maximizing points through greedy choices with energy validatio…
Alternating Groups II
Solve the problem of counting alternating groups in a circle of tiles using a sliding window approach.
Number of Subarrays With AND Value of K
The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…
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.
Construct String with Minimum Cost
This problem asks you to construct a target string using given words at minimal cost using dynamic programming technique…
Delete Nodes From Linked List Present in Array
Remove nodes from a linked list if their values exist in a given array.
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.
Minimum Cost for Cutting Cake II
Solve Minimum Cost for Cutting Cake II by choosing optimal cuts using a greedy strategy while tracking cost increments p…
Minimum Array Changes to Make Differences Equal
Minimize changes to make array differences equal by replacing elements within a given range.
Maximum Score From Grid Operations
Maximize your score by choosing the optimal sequence of column operations on a grid using dynamic programming transition…
Minimum Operations to Make Array Equal to Target
This problem requires calculating the minimum number of operations to transform one array into another using state trans…
Find if Digit Game Can Be Won
Determine if Alice can guarantee a win in a game by selectively summing single or double-digit numbers from an array.
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.
Check if the Rectangle Corner Is Reachable
Determine if there is a valid path from the bottom-left to top-right of a rectangle while avoiding circles.
Find the Number of Winning Players
Find how many players in a game win by picking more balls of a single color than their index position.
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…
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…
Design Neighbor Sum Service
Design a service that computes sums for adjacent and diagonal elements in a 2D grid.
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…
Shortest Distance After Road Addition Queries II
The problem involves calculating the shortest path from city 0 to city n-1 after each road addition, leveraging greedy c…
Alternating Groups III
Solve Alternating Groups III using array manipulation and a binary indexed tree to track maximal alternating sequences e…
Snake in Matrix
Solve the Snake in Matrix problem by simulating the snake's movement in a grid based on a series of directional commands…
Find the Count of Monotonic Pairs I
Compute the number of monotonic pairs in an integer array using state transition dynamic programming efficiently.
Find the Count of Monotonic Pairs II
This problem involves finding the count of monotonic pairs in an array using dynamic programming and combinatorics techn…
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.
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.
Maximum Value Sum by Placing Three Rooks I
Maximize the value sum by placing three rooks on a chessboard while ensuring they do not attack each other.
Maximum Value Sum by Placing Three Rooks II
Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.
Maximum Energy Boost From Two Drinks
Maximize energy boost from two drinks with a state transition dynamic programming approach.
Count Substrings That Satisfy K-Constraint II
Count Substrings That Satisfy K-Constraint II requires finding valid substrings in a binary string based on a k-constrai…
Final Array State After K Multiplication Operations I
Solve the problem of determining the final state of an array after multiple multiplication operations using a priority q…
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.
Final Array State After K Multiplication Operations II
Optimize the final state of an array after performing k multiplication operations with priority queues.
Count Almost Equal Pairs II
Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.
Minimum Amount of Damage Dealt to Bob
Minimize the total damage dealt to Bob using power to eliminate enemies efficiently with greedy approach.
K-th Nearest Obstacle Queries
Solve the K-th nearest obstacle query problem using array and heap (priority queue) techniques to find distances efficie…
Select Cells in Grid With Maximum Score
Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.
Maximum XOR Score Subarray Queries
Solve the Maximum XOR Score Subarray Queries problem using state transition dynamic programming for optimal subarray com…
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…
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.
Maximum Number of Moves to Kill All Pawns
Calculate the maximum number of moves to eliminate all pawns using BFS, bitmasking, and precise array position math effi…
Find Indices of Stable Mountains
Find the indices of stable mountains in an array of mountain heights based on a threshold.
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.
Find the Maximum Sequence Value of Array
Determine the maximum value of a subsequence in an integer array using state transition dynamic programming and bit oper…
Length of the Longest Increasing Path
Determine the maximum length of an increasing path in a 2D array using binary search over potential path lengths efficie…
The Two Sneaky Numbers of Digitville
Find the two numbers that appear twice in a list of integers from 0 to n-1 using array scanning plus hash lookup efficie…
Maximum Multiplication Score
The problem requires selecting four indices from an array to maximize a dynamic score with a transition approach.
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…
Minimum Number of Valid Strings to Form Target II
Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…
Report Spam Message
Determine if a message contains at least two banned words using array scanning and hash lookup.
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.
Minimum Element After Replacement With Digit Sum
Replace each number with its digit sum and return the smallest resulting value, using array plus math techniques efficie…
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.
Maximum Possible Number by Binary Concatenation
Determine the largest number achievable by reordering three integers and concatenating their binary forms efficiently.
Construct 2D Grid Matching Graph Layout
This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.
Sorted GCD Pair Queries
Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…
Construct the Minimum Bitwise Array I
Learn how to construct an array minimizing each element while matching given primes using bitwise operations efficiently…
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.
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…
Find X-Sum of All K-Long Subarrays I
Compute the x-sum of every subarray of length k efficiently using array scanning combined with hash lookup techniques.
Find X-Sum of All K-Long Subarrays II
Calculate the x-sum for every k-length subarray using efficient array scanning and hash-based counting techniques.
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…
Check if DFS Strings Are Palindromes
Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…
Find Subtree Sizes After Changes
Calculate the sizes of all subtrees after simultaneous parent changes using array scanning and hash-based counting effic…
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.
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…
Find the Number of Subsequences With Equal GCD
Count all pairs of non-empty subsequences in an integer array whose elements share the same greatest common divisor effi…
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…
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.
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…
Maximum Frequency of an Element After Performing Operations II
Determine the maximum frequency of any element after performing limited operations using binary search and sliding windo…
Adjacent Increasing Subarrays Detection I
Check if an array contains two adjacent strictly increasing subarrays of length k using an array-driven approach efficie…
Adjacent Increasing Subarrays Detection II
Find the largest k where two adjacent strictly increasing subarrays of length k exist using binary search techniques.
Sum of Good Subsequences
Calculate the sum of all good subsequences in an array where consecutive numbers differ by exactly one.
Make Array Elements Equal to Zero
Learn how to transform an integer array to zeros using simulation and directional selection efficiently and reliably.
Zero Array Transformation I
Transform the given integer array into a zero array using range operations, focusing on prefix sum optimization and care…
Zero Array Transformation II
Zero Array Transformation II requires determining the minimum query sequence to convert all array elements to zero using…
Minimize the Maximum Adjacent Element Difference
Minimize the maximum adjacent element difference by filling missing values with two chosen numbers.
Shift Distance Between Two Strings
Find the minimum cost of transforming one string into another, considering operations between characters.
Zero Array Transformation III
Zero Array Transformation III requires removing the minimum number of queries to make all elements zero using greedy val…
Find the Maximum Number of Fruits Collected
Maximize the number of fruits collected by three children navigating a grid dungeon with dynamic programming.
Minimum Positive Sum Subarray
Find the minimum sum of any subarray of size between l and r with a positive total using efficient sliding window logic.
Minimum Array Sum
Solve the Minimum Array Sum problem using dynamic programming by tracking states and operations to minimize the sum of a…
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.
Minimum Operations to Make Array Values Equal to K
Find the minimum operations to convert an array to all values equal k using array scanning and hash lookup efficiently.
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…
Count Connected Components in LCM Graph
Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…
Transformed Array
Simulate operations on a circular array to return a transformed result array following specific rules.
Maximum Area Rectangle With Point Constraints I
Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.
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.
Maximum Area Rectangle With Point Constraints II
Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…
Button with Longest Push Time
Determine which button a child pressed the longest using an array-driven strategy to track time differences efficiently.
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.
Count Beautiful Splits in an Array
Learn to count all valid beautiful splits in an array using state transition dynamic programming efficiently and accurat…
Count Subarrays of Length Three With a Condition
Determine how many subarrays of length three satisfy a sum condition on their first and third elements in an array.
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.
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.
Subsequences with a Unique Middle Mode I
Count subsequences of size 5 with a unique middle mode in an integer array using hash table and combinatorics.
Minimum Number of Operations to Make Elements in Array Distinct
Find the minimum number of operations to make all elements of an array distinct.
Maximum Number of Distinct Elements After Operations
Maximize distinct elements in an array by performing at most one operation on each element.
Smallest Substring With Identical Characters I
Minimize the length of the longest substring with identical characters after at most numOps changes in a binary string.
Minimum Operations to Make Columns Strictly Increasing
Calculate the minimum increments to make each column of a matrix strictly increasing using a greedy invariant approach.
Count Special Subsequences
Count the number of special subsequences in an array of positive integers, focusing on efficient array scanning and hash…
Longest Subsequence With Decreasing Adjacent Difference
Find the length of the longest subsequence with non-increasing absolute adjacent differences.
Maximize Subarray Sum After Removing All Occurrences of One Element
Maximize Subarray Sum After Removing All Occurrences of One Element involves finding the optimal subarray sum with one a…
Maximum Subarray With Equal Products
This problem involves finding the longest subarray where the product equals the LCM multiplied by the GCD, leveraging a …
Maximum Coins From K Consecutive Bags
Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…
Maximum Score of Non-overlapping Intervals
Maximize the score of up to 4 non-overlapping intervals, considering their weight and ensuring no overlap between chosen…
Zigzag Grid Traversal With Skip
Traverse a 2D grid in a zigzag pattern while skipping alternate cells, focusing on array and matrix manipulation challen…
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.
Count Non-Decreasing Subarrays After K Operations
This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.
Maximum Difference Between Adjacent Elements in a Circular Array
Find the maximum absolute difference between adjacent elements in a circular array using a straightforward array-driven …
Minimum Cost to Make Arrays Identical
Minimize cost to make arrays identical by performing operations with given constraints and a greedy strategy.
Longest Special Path
Compute the longest downward path in a tree with unique node values using DFS, hash lookup, and careful array scanning.
Sum of Variable Length Subarrays
Calculate the total sum of all elements in subarrays defined for each index in an array, using the array plus prefix sum…
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.
Paint House IV
Solve the Paint House IV problem using state transition dynamic programming to minimize the painting costs while adherin…
Maximum and Minimum Sums of at Most Size K Subarrays
Compute the sum of maximum and minimum values in all subarrays up to size k using efficient stack-based state management…
Count Partitions with Even Sum Difference
Count the number of partitions with an even sum difference from an array of integers.
Count Mentions Per User
Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…
Maximum Frequency After Subarray Operation
Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…
Frequencies of Shortest Supersequences
Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …
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.
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…
Minimum Increments for Target Multiples in an Array
This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…
Sort Matrix by Diagonals
Sort Matrix by Diagonals groups cells by diagonal, then sorts bottom-left diagonals descending and top-right diagonals a…
Assign Elements to Groups with Constraints
Assign elements to groups by size constraints with a sieve-like approach to find suitable element matches efficiently.
Maximize the Minimum Game Score
Maximizing the minimum score after at most m moves, leveraging binary search and greedy strategies over an array of scor…
Sum of Good Numbers
The problem asks for the sum of all good numbers in an array based on specific conditions of neighboring elements.
Separate Squares I
Find the minimum y-coordinate of a horizontal line that balances the areas of squares above and below it.
Separate Squares II
Separate Squares II requires finding the minimum y-coordinate such that squares' areas are split evenly above and below …
Eat Pizzas!
Maximize the total weight gained by optimally eating pizzas in groups of four using greedy selection and invariant valid…
Length of Longest V-Shaped Diagonal Segment
Compute the maximum length of a V-shaped diagonal segment in a 2D integer matrix using state transition dynamic programm…
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.
Maximize the Distance Between Points on a Square
Select k points on a square boundary to maximize minimum Manhattan distance using binary search and greedy placement str…
Transform Array by Parity
Transform an array by sorting even numbers first, followed by odd numbers.
Find the Number of Copy Arrays
Find the number of possible arrays by leveraging bounds and math in this array-based problem.
Find Minimum Cost to Remove Array Elements
Find the minimum cost to remove all elements from the array with dynamic programming.
Permutations IV
Find the k-th alternating permutation of numbers 1 to n, ensuring no adjacent numbers share parity, using array and math…
Find the Largest Almost Missing Integer
Find the largest almost missing integer in an array where it appears in exactly one subarray of size k.
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…
Fruits Into Baskets II
Determine the number of fruit types that remain unplaced after all allocations in the "Fruits Into Baskets II" problem.
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…
Fruits Into Baskets III
Fruits Into Baskets III requires placing fruits into baskets efficiently using binary search over the answer space for c…
Maximize Subarrays After Removing One Conflicting Pair
Maximize the count of subarrays after removing one conflicting pair using array traversal and segment tree logic efficie…
Unique 3-Digit Even Numbers
Given an array of digits, find how many distinct 3-digit even numbers can be formed without repetition of digits and no …
Design Spreadsheet
Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…
Longest Common Prefix of K Strings After Removal
Find the longest common prefix length of k strings after removing an element in the array.
Longest Special Path II
Find the longest downward path in a tree where node values are mostly distinct, allowing one repeat, using array scannin…
Maximum Unique Subarray Sum After Deletion
Maximize the sum of a subarray after performing deletions, ensuring elements remain unique.
Closest Equal Element Queries
Find the nearest index with the same value for each query using array scanning combined with hash lookups efficiently.
Properties Graph
Find the number of connected components in an undirected graph formed by properties arrays, using array scanning and has…
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…
Minimum Operations to Make Array Elements Zero
Minimize operations to reduce array elements to zero, focusing on array manipulation, math, and bit operations for effic…
Minimum Cost to Divide Array Into Subarrays
Optimize array splits with dynamic programming to minimize costs for the Minimum Cost to Divide Array Into Subarrays pro…
Maximize Active Section with Trade II
Maximize the number of active sections in a binary string with at most one trade.
Minimum Cost to Reach Every Position
Calculate the minimum swap costs to reach each position in a line using a precise array-driven strategy for efficiency.
Minimum Operations to Make Elements Within K Subarrays Equal
Compute the minimum operations to ensure at least k non-overlapping subarrays of size x have all equal elements efficien…
Minimum Pair Removal to Sort Array I
This problem asks for the minimum number of operations to make an array non-decreasing by removing pairs of elements.
Implement Router
Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.
Maximum Product of Subsequences With an Alternating Sum Equal to K
Find the maximum product of a subsequence in an array with an alternating sum equal to a given target.
Minimum Pair Removal to Sort Array II
The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.
Minimum Operations to Make Array Sum Divisible by K
This problem asks you to find the minimum operations to make the sum of an array divisible by a given integer k.
Number of Unique XOR Triplets I
Calculate all unique XOR triplet values in a permutation array using array traversal and bit manipulation techniques eff…
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…
Shortest Path in a Weighted Tree
Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.
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…
Make Array Non-decreasing
Determine the maximum size of a non-decreasing array by replacing subarrays with their maximum values efficiently.
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…
Find X Value of Array II
The "Find X Value of Array II" problem requires calculating the number of ways to remove a suffix from an array such tha…
Find the Most Common Response
Find the most common survey response after eliminating duplicates within each day, using array scanning and hash lookups…
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…
Maximum Profit from Valid Topological Order in DAG
Solve the Maximum Profit from Valid Topological Order in DAG problem using graph indegree and topological sorting with d…
Count Covered Buildings
Determine how many buildings in an n x n city are completely surrounded using array scanning and hash lookup efficiently…
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.
Concatenated Divisibility
Find the lexicographically smallest permutation of numbers whose concatenation is divisible by k using state transition …
Path Existence Queries in a Graph II
Solve path existence queries in a graph using binary search on the answer space, focusing on sorted nodes and maximum di…
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…
Merge Operations for Minimum Travel Time
Minimize the total travel time by merging road signs, using dynamic programming to manage state transitions efficiently.
Find Sum of Array Product of Magical Sequences
Use state transition dynamic programming to count magical index sequences and accumulate weighted products without enume…
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.
Subtree Inversion Sum
This problem involves calculating the maximum possible subtree inversion sum with dynamic programming and binary-tree tr…
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…
Equal Sum Grid Partition II
Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.
Smallest Index With Digit Sum Equal to Index
Find the smallest index in an array where the sum of the digits equals the index.
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.
Grid Teleportation Traversal
Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.
Minimum Weighted Subgraph With the Required Paths II
Solve the Minimum Weighted Subgraph With the Required Paths II problem by leveraging binary-tree traversal and efficient…
Number of Ways to Assign Edge Weights II
This problem involves assigning edge weights in a tree and calculating the cost of paths based on these weights.
Maximum Profit from Trading Stocks with Discounts
Solve the Maximum Profit from Trading Stocks with Discounts problem using binary-tree traversal and dynamic state tracki…
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.
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.
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.
Maximize Count of Distinct Primes After Split
Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…
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…
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…
Maximize Subarray GCD Score
Maximize Subarray GCD Score focuses on maximizing a subarray's score by using at most k doubling operations on an array …
Maximum Good Subtree Score
Find the maximum sum of values in a tree subtree without repeating any digit across selected nodes using DFS and bitmask…
Transform Array to All Equal Elements
Transform Array to All Equal Elements requires careful greedy choices and validating invariants to achieve uniformity ef…
Count the Number of Computer Unlocking Permutations
Calculate the total valid unlocking sequences for computers based on their complexity using array and combinatorics logi…
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.
Count Special Triplets
Count Special Triplets requires scanning an array while tracking counts of previous and next values efficiently with has…
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.
Find Weighted Median Node in Tree
Given a weighted tree and queries, find the weighted median node for each path between two nodes using binary-tree trave…
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…
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.
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…
Kth Smallest Path XOR Sum
This problem involves finding the kth smallest distinct XOR sum for nodes in a subtree of a tree structure using binary-…
Check if Any Element Has Prime Frequency
Check if any element in the array has a prime frequency count, leveraging array scanning and hash table lookup.
Inverse Coin Change
Recover coin denominations from a numWays array using state transition dynamic programming to reconstruct valid sets eff…
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.
Minimum Time to Transport All Individuals
Find the minimum time to transport individuals across a river with dynamic environmental conditions and boat capacity.
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.
Partition Array to Minimize XOR
Partition an integer array into k subarrays to minimize the maximum XOR using state transition dynamic programming effic…
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.
Minimum Stability Factor of Array
The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…
Coupon Code Validator
The Coupon Code Validator problem requires filtering and sorting coupons based on specific criteria for validity.
Power Grid Maintenance
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…
Split Array by Prime Indices
Split Array by Prime Indices challenges you to separate elements at prime positions and minimize the absolute sum differ…
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.
Network Recovery Pathways
Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.
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…
Number of Integers With Popcount-Depth Equal to K II
This problem challenges you to efficiently calculate the number of integers with popcount-depth equal to K using array a…
Count Number of Trapezoids II
Count Number of Trapezoids II requires scanning point pairs and hashing slopes to efficiently find parallel sides in arr…
Partition Array for Maximum XOR and AND
Partition the array into three subsequences to maximize XOR and AND operations with a greedy approach.
Related Patterns
Array scanning plus hash lookup
418 linked problems
State transition dynamic programming
278 linked problems
Binary search over the valid answer space
158 linked problems
Greedy choice plus invariant validation
130 linked problems
Array plus Math
111 linked problems
Two-pointer scanning with invariant tracking
60 linked problems