LeetCodechevron_rightCategorieschevron_rightprefix sum
data_array

prefix sum

186 problems
Easy: 19Medium: 113Hard: 54

prefix sum 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

#TitleDifficulty
209

Minimum Size Subarray Sum

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

Medium
238

Product of Array Except Self

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

Medium
303

Range Sum Query - Immutable

The Range Sum Query - Immutable problem involves implementing a data structure to handle range sum queries efficiently.

Easy
304

Range Sum Query 2D - Immutable

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

Medium
363

Max Sum of Rectangle No Larger Than K

Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…

Hard
410

Split Array Largest Sum

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

Hard
497

Random Point in Non-overlapping Rectangles

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

Medium
523

Continuous Subarray Sum

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

Medium
525

Contiguous Array

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

Medium
528

Random Pick with Weight

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

Medium
560

Subarray Sum Equals K

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

Medium
689

Maximum Sum of 3 Non-Overlapping Subarrays

Maximize the sum of three non-overlapping subarrays with length k in an integer array using dynamic programming.

Hard
713

Subarray Product Less Than K

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

Medium
724

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…

Easy
731

My Calendar II

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

Medium
732

My Calendar III

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

Hard
798

Smallest Rotation with Highest Score

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

Hard
813

Largest Sum of Averages

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

Medium
848

Shifting Letters

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

Medium
862

Shortest Subarray with Sum at Least K

Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.

Hard
903

Valid Permutations for DI Sequence

The problem asks to find the number of valid permutations for a given DI sequence string using dynamic programming and s…

Hard
930

Binary Subarrays With Sum

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

Medium
974

Subarray Sums Divisible by K

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

Medium
995

Minimum Number of K Consecutive Bit Flips

Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…

Hard
1000

Minimum Cost to Merge Stones

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

Hard
1004

Max Consecutive Ones III

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

Medium
1074

Number of Submatrices That Sum to Target

Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…

Hard
1094

Car Pooling

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

Medium
1109

Corporate Flight Bookings

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

Medium
1124

Longest Well-Performing Interval

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

Medium
1140

Stone Game II

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

Medium
1177

Can Make Palindrome from Substring

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

Medium
1208

Get Equal Substrings Within Budget

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

Medium
1248

Count Number of Nice Subarrays

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

Medium
1292

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

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

Medium
1310

XOR Queries of a Subarray

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

Medium
1314

Matrix Block Sum

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

Medium
1352

Product of the Last K Numbers

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

Medium
1371

Find the Longest Substring Containing Vowels in Even Counts

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

Medium
1413

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.

Easy
1420

Build Array Where You Can Find The Maximum Exactly K Comparisons

This problem asks to build an array where the maximum element is found using exactly K comparisons, with dynamic program…

Hard
1422

Maximum Score After Splitting a String

Find the optimal split point in a binary string to maximize zeros on the left and ones on the right efficiently.

Easy
1423

Maximum Points You Can Obtain from Cards

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

Medium
1442

Count Triplets That Can Form Two Arrays of Equal XOR

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

Medium
1444

Number of Ways of Cutting a Pizza

This problem challenges you to determine the number of valid ways to cut a pizza into pieces with apples using dynamic p…

Hard
1480

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.

Easy
1508

Range Sum of Sorted Subarray Sums

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

Medium
1524

Number of Sub-arrays With Odd Sum

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

Medium
1546

Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

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

Medium
1588

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.

Easy
1589

Maximum Sum Obtained of Any Permutation

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

Medium
1590

Make Sum Divisible by P

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

Medium
1658

Minimum Operations to Reduce X to Zero

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

Medium
1664

Ways to Make a Fair Array

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

Medium
1674

Minimum Moves to Make Array Complementary

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

Medium
1685

Sum of Absolute Differences in a Sorted Array

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

Medium
1687

Delivering Boxes from Storage to Ports

Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…

Hard
1703

Minimum Adjacent Swaps for K Consecutive Ones

Find the minimum number of adjacent swaps to gather k consecutive ones in a binary array using sliding window logic.

Hard
1712

Ways to Split Array Into Three Subarrays

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

Medium
1732

Find the Highest Altitude

Find the highest altitude after a series of altitude changes during a road trip using prefix sum technique.

Easy
1737

Change Minimum Characters to Satisfy One of Three Conditions

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

Medium
1738

Find Kth Largest XOR Coordinate Value

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

Medium
1744

Can You Eat Your Favorite Candy on Your Favorite Day?

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

Medium
1769

Minimum Number of Operations to Move All Balls to Each Box

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

Medium
1829

Maximum XOR for Each Query

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

Medium
1838

Frequency of the Most Frequent Element

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

Medium
1854

Maximum Population Year

Find the earliest year with the highest population using an array plus counting approach.

Easy
1856

Maximum Subarray Min-Product

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

Medium
1862

Sum of Floored Pairs

The problem asks to calculate the sum of floor divisions for all pairs in a given integer array, using an efficient meth…

Hard
1871

Jump Game VII

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

Medium
1872

Stone Game VIII

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

Hard
1878

Get Biggest Three Rhombus Sums in a Grid

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

Medium
1889

Minimum Space Wasted From Packaging

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

Hard
1893

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.

Easy
1894

Find the Student that Will Replace the Chalk

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

Medium
1895

Largest Magic Square

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

Medium
1915

Number of Wonderful Substrings

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

Medium
1930

Unique Length-3 Palindromic Subsequences

Count all unique length-3 palindromic subsequences in a string efficiently using hash tables and character positions.

Medium
1943

Describe the Painting

Solve the problem of describing a painted segment with mixed colors using array scanning and hash table lookups.

Medium
1991

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…

Easy
2017

Grid Game

Solve the Grid Game problem by optimizing the movement of two robots on a 2D matrix grid.

Medium
2024

Maximize the Confusion of an Exam

Maximize the Confusion of an Exam requires adjusting at most k answers to create the longest consecutive true or false s…

Medium
2025

Maximum Number of Ways to Partition an Array

Determine the maximum number of ways to split an array into equal sums using at most one element change, leveraging pref…

Hard
2055

Plates Between Candles

Determine the number of plates between candles in a given substring using binary search and prefix sum techniques.

Medium
2100

Find Good Days to Rob the Bank

Find good days to rob the bank by identifying days with non-increasing and non-decreasing guard counts using dynamic pro…

Medium
2106

Maximum Fruits Harvested After at Most K Steps

Compute the maximum fruits collectable on an infinite line by moving at most k steps from a start position efficiently.

Hard
2121

Intervals Between Identical Elements

Solve the problem of calculating intervals between identical elements using array scanning and hash lookup.

Medium
2132

Stamping the Grid

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

Hard
2145

Count the Hidden Sequences

Given a sequence of differences, count how many hidden sequences fit within a range using an array and prefix sum approa…

Medium
2171

Removing Minimum Number of Magic Beans

Determine the minimum beans to remove so all remaining non-empty bags have equal beans using a greedy approach.

Medium
2207

Maximize Number of Subsequences in a String

Maximize the number of subsequences by optimally adding a character to a given string to match a specified pattern.

Medium
2209

Minimum White Tiles After Covering With Carpets

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

Hard
2218

Maximum Value of K Coins From Piles

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

Hard
2222

Number of Ways to Select Buildings

Solve Number of Ways to Select Buildings by counting alternating 3-building patterns with state transitions over the bin…

Medium
2234

Maximum Total Beauty of the Gardens

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

Hard
2245

Maximum Trailing Zeros in a Cornered Path

Find the maximum trailing zeros in the product of a cornered path within a 2D grid.

Medium
2251

Number of Flowers in Full Bloom

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

Hard
2256

Minimum Average Difference

Find the index with the minimum average difference in an array using prefix sums.

Medium
2270

Number of Ways to Split Array

Count all valid ways to split a 0-indexed integer array into two non-empty parts using array plus prefix sum logic effic…

Medium
2271

Maximum White Tiles Covered by a Carpet

Solve Maximum White Tiles Covered by a Carpet by sorting intervals, checking optimal carpet starts, and counting full pl…

Medium
2281

Sum of Total Strength of Wizards

The Sum of Total Strength of Wizards problem asks for the sum of the total strengths of all contiguous subarrays of wiza…

Hard
2302

Count Subarrays With Score Less Than K

Count all non-empty subarrays whose score, defined as sum times length, is strictly less than a given integer k efficien…

Hard
2381

Shifting Letters II

Shift letters in a string using a sequence of range-based forward or backward operations efficiently with prefix sums.

Medium
2382

Maximum Segment Sum After Removals

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

Hard
2389

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.

Easy
2391

Minimum Amount of Time to Collect Garbage

This problem asks you to find the minimum amount of time needed to collect all garbage in a city, focusing on array and …

Medium
2398

Maximum Number of Robots Within Budget

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

Hard
2406

Divide Intervals Into Minimum Number of Groups

Determine the minimum number of non-overlapping groups for a set of intervals using precise two-pointer scanning logic.

Medium
2420

Find All Good Indices

Identify all indices in an array where the k-length prefix is non-increasing and the k-length suffix is non-decreasing.

Medium
2428

Maximum Sum of an Hourglass

Calculate the maximum sum of an hourglass in a 2D matrix using array traversal and submatrix evaluation techniques effic…

Medium
2438

Range Product Queries of Powers

The Range Product Queries of Powers problem requires calculating the product of powers of 2 for a range of queries on a …

Medium
2439

Minimize Maximum of Array

Minimize Maximum of Array involves finding the smallest possible maximum value after applying a series of operations on …

Medium
2448

Minimum Cost to Make Array Equal

Find the minimum cost to make all elements of an array equal by using binary search over valid answers.

Hard
2483

Minimum Penalty for a Shop

Determine the earliest closing hour of a shop to minimize penalty using a string of customer visits and prefix sums.

Medium
2485

Find the Pivot Integer

Find the Pivot Integer problem challenges you to identify an integer x that balances prefix sums on both sides.

Easy
2488

Count Subarrays With Median K

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

Hard
2528

Maximize the Minimum Powered City

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

Hard
2536

Increment Submatrices by One

Increment Submatrices by One focuses on efficiently updating submatrices using row-wise prefix sums in an n by n matrix.

Medium
2552

Count Increasing Quadruplets

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

Hard
2559

Count Vowel Strings in Ranges

Count the number of strings that start and end with a vowel in given ranges within an array of words.

Medium
2574

Left and Right Sum Differences

Compute absolute differences between left and right cumulative sums for each element in an integer array efficiently.

Easy
2587

Rearrange Array to Maximize Prefix Score

Maximize the number of positive prefix sums by rearranging an integer array using a greedy, order-focused strategy.

Medium
2588

Count the Number of Beautiful Subarrays

Count the Number of Beautiful Subarrays is a Medium-level problem involving array scanning and hash table lookup to find…

Medium
2602

Minimum Operations to Make All Array Elements Equal

Find the minimum number of operations to make all elements in an array equal for each query.

Medium
2615

Sum of Distances

In this problem, you calculate an array where each element is the sum of absolute differences of indices for equal value…

Medium
2640

Find the Score of All Prefixes of an Array

Compute the score of each prefix in an array using conversion rules while tracking the maximum efficiently for prefix su…

Medium
2680

Maximum OR

Maximize the bitwise OR of an array by applying at most k multiplication operations on selected elements.

Medium
2681

Power of Heroes

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

Hard
2731

Movement of Robots

Calculate total distances between robots moving on a number line while accounting for collisions using array plus braint…

Medium
2772

Apply Operations to Make All Array Elements Equal to Zero

Determine if all elements in a given array can be reduced to zero using repeated k-length prefix operations efficiently.

Medium
2845

Count of Interesting Subarrays

Count all subarrays where the number of elements satisfying a modulo condition equals a target k using efficient prefix …

Medium
2848

Points That Intersect With Cars

Count covered integer points by merging overlapping car intervals or marking visited positions on the number line.

Easy
2875

Minimum Size Subarray in Infinite Array

Find the shortest subarray in an infinite array that sums to a given target using array scanning and hash lookup.

Medium
2906

Construct Product Matrix

Solve the "Construct Product Matrix" problem by calculating the product of elements in 2D matrices without division.

Medium
2947

Count Beautiful Substrings I

Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.

Medium
2949

Count Beautiful Substrings II

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

Hard
2968

Apply Operations to Maximize Frequency Score

Maximize the frequency score by applying up to k operations on a sorted array using binary search over valid answer spac…

Hard
2971

Find Polygon With the Largest Perimeter

Determine the largest perimeter polygon from a set of side lengths using a greedy approach with invariant validation che…

Medium
2983

Palindrome Rearrangement Queries

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

Hard
3015

Count the Number of Houses at a Certain Distance I

Determine the number of house pairs at each street distance using graph traversal and breadth-first search efficiently.

Medium
3017

Count the Number of Houses at a Certain Distance II

Count the Number of Houses at a Certain Distance II is a graph problem that requires efficient pair counting with an add…

Hard
3026

Maximum Good Subarray Sum

Find the maximum sum of any subarray where the first and last elements differ by exactly k using efficient array scannin…

Medium
3028

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.

Easy
3070

Count Submatrices with Top-Left Element and Sum Less Than k

Count all submatrices including the top-left element with sum less than k using array and matrix prefix sum strategies.

Medium
3077

Maximum Strength of K Disjoint Subarrays

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

Hard
3086

Minimum Moves to Pick K Ones

Find the minimum number of moves to pick exactly k ones from a binary array, considering a constraint on changes.

Hard
3096

Minimum Levels to Gain More Points

Determine the minimum number of levels Alice must play in a binary game array to secure more points than Bob using prefi…

Medium
3129

Find All Possible Stable Binary Arrays I

Find all stable binary arrays of a given number of 0's, 1's, and limit using dynamic programming and state transitions.

Medium
3130

Find All Possible Stable Binary Arrays II

Compute the number of stable binary arrays using state transition dynamic programming with exact zero, one, and limit co…

Hard
3147

Taking Maximum Energy From the Mystic Dungeon

Maximize your energy by strategically jumping through magicians using array and prefix sum techniques for optimal path c…

Medium
3152

Special Array II

Determine whether each subarray meets the special condition of alternating parity for all adjacent elements efficiently …

Medium
3179

Find the N-th Value After K Seconds

Solve for the N-th value after K seconds by simulating array updates and using prefix sum techniques.

Medium
3191

Minimum Operations to Make Binary Array Elements Equal to One I

Find the minimum number of operations to make all elements of a binary array equal to one using sliding window and state…

Medium
3212

Count Submatrices With Equal Frequency of X and Y

Count the number of submatrices with equal frequency of 'X' and 'Y' in a 2D character grid.

Medium
3224

Minimum Array Changes to Make Differences Equal

Minimize changes to make array differences equal by replacing elements within a given range.

Medium
3225

Maximum Score From Grid Operations

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

Hard
3250

Find the Count of Monotonic Pairs I

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

Hard
3251

Find the Count of Monotonic Pairs II

This problem involves finding the count of monotonic pairs in an array using dynamic programming and combinatorics techn…

Hard
3261

Count Substrings That Satisfy K-Constraint II

Count Substrings That Satisfy K-Constraint II requires finding valid substrings in a binary string based on a k-constrai…

Hard
3312

Sorted GCD Pair Queries

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

Hard
3333

Find the Original Typed String II

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

Hard
3346

Maximum Frequency of an Element After Performing Operations I

Maximize the frequency of an element in an array after performing a series of operations to find the best possible resul…

Medium
3347

Maximum Frequency of an Element After Performing Operations II

Determine the maximum frequency of any element after performing limited operations using binary search and sliding windo…

Hard
3354

Make Array Elements Equal to Zero

Learn how to transform an integer array to zeros using simulation and directional selection efficiently and reliably.

Easy
3355

Zero Array Transformation I

Transform the given integer array into a zero array using range operations, focusing on prefix sum optimization and care…

Medium
3356

Zero Array Transformation II

Zero Array Transformation II requires determining the minimum query sequence to convert all array elements to zero using…

Medium
3361

Shift Distance Between Two Strings

Find the minimum cost of transforming one string into another, considering operations between characters.

Medium
3362

Zero Array Transformation III

Zero Array Transformation III requires removing the minimum number of queries to make all elements zero using greedy val…

Medium
3364

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.

Easy
3381

Maximum Subarray Sum With Length Divisible by K

Find the maximum sum of a subarray where the length of the subarray is divisible by k.

Medium
3413

Maximum Coins From K Consecutive Bags

Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…

Medium
3425

Longest Special Path

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

Hard
3427

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…

Easy
3432

Count Partitions with Even Sum Difference

Count the number of partitions with an even sum difference from an array of integers.

Easy
3434

Maximum Frequency After Subarray Operation

Determine the maximum frequency of a target value k after applying one subarray addition operation efficiently using arr…

Medium
3445

Maximum Difference Between Even and Odd Frequency II

Find the maximum difference between even and odd character frequencies in substrings using sliding window updates effici…

Hard
3473

Sum of K Subarrays With Length at Least M

Maximize the sum of k non-overlapping subarrays of at least length m using dynamic programming and prefix sums efficient…

Medium
3480

Maximize Subarrays After Removing One Conflicting Pair

Maximize the count of subarrays after removing one conflicting pair using array traversal and segment tree logic efficie…

Hard
3486

Longest Special Path II

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

Hard
3494

Find the Minimum Amount of Time to Brew Potions

This problem involves calculating the minimum time required for wizards to brew potions based on their skills and mana u…

Medium
3500

Minimum Cost to Divide Array Into Subarrays

Optimize array splits with dynamic programming to minimize costs for the Minimum Cost to Divide Array Into Subarrays pro…

Hard
3538

Merge Operations for Minimum Travel Time

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

Hard
3546

Equal Sum Grid Partition I

Determine if an m x n matrix grid can be split into two non-empty sections with equal sums by making a single horizontal…

Medium
3548

Equal Sum Grid Partition II

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

Hard
3578

Count Partitions With Max-Min Difference at Most K

Count the number of valid ways to partition an array into contiguous segments where max-min difference is at most k.

Medium
3599

Partition Array to Minimize XOR

Partition an integer array into k subarrays to minimize the maximum XOR using state transition dynamic programming effic…

Medium

Related Patterns

Prefix Sum LeetCode Problems: 186 Solutions