Prefix Sum Pattern

Precompute cumulative sums for O(1) range queries.

#Title
1664Ways to Make a Fair Array
1703Minimum Adjacent Swaps for K Consecutive Ones
1712Ways to Split Array Into Three Subarrays
1737Change Minimum Characters to Satisfy One of Three Conditions
1744Can You Eat Your Favorite Candy on Your Favorite Day?
1749Maximum Absolute Sum of Any Subarray
1856Maximum Subarray Min-Product
1906Minimum Absolute Difference Queries
1937Maximum Number of Points with Cost
1966Binary Searchable Numbers in an Unsorted Array
1983Widest Pair of Indices With Equal Range Sum
1991Find the Middle Index in Array
2012Sum of Beauty in the Array
2017Grid Game
2025Maximum Number of Ways to Partition an Array
2031Count Subarrays With More Ones Than Zeros
2055Plates Between Candles
2100Find Good Days to Rob the Bank
2106Maximum Fruits Harvested After at Most K Steps
2121Intervals Between Identical Elements
2132Stamping the Grid
2155All Divisions With the Highest Score of a Binary Array
2163Minimum Difference in Sums After Removal of Elements
2219Maximum Sum Score of Array
2234Maximum Total Beauty of the Gardens
2245Maximum Trailing Zeros in a Cornered Path
2256Minimum Average Difference
2270Number of Ways to Split Array
2271Maximum White Tiles Covered by a Carpet
2281Sum of Total Strength of Wizards
2382Maximum Segment Sum After Removals
2391Minimum Amount of Time to Collect Garbage
2409Count Days Spent Together
2420Find All Good Indices
2438Range Product Queries of Powers
2448Minimum Cost to Make Array Equal
2463Minimum Total Distance Traveled
2484Count Palindromic Subsequences
2488Count Subarrays With Median K
2489Number of Substrings With Fixed Ratio
2503Maximum Number of Points From Grid Queries
2552Count Increasing Quadruplets
2554Maximum Number of Integers to Choose From a Range I
2557Maximum Number of Integers to Choose From a Range II
2559Count Vowel Strings in Ranges
2574Left and Right Sum Differences
2575Find the Divisibility Array of a String
2599Make the Prefix Sum Non-negative
2602Minimum Operations to Make All Array Elements Equal
2615Sum of Distances
2640Find the Score of All Prefixes of an Array
2670Find the Distinct Difference Array
2680Maximum OR
2711Difference of Number of Distinct Values on Diagonals
2735Collecting Chocolates
2790Maximum Number of Groups With Increasing Length
2819Minimum Relative Loss After Buying Chocolates
2836Maximize Value of Function in a Ball Passing Game
2845Count of Interesting Subarrays
2875Minimum Size Subarray in Infinite Array
2903Find Indices With Index and Value Difference I
2905Find Indices With Index and Value Difference II
2906Construct Product Matrix
2907Maximum Profitable Triplets With Increasing Prices I
2908Minimum Sum of Mountain Triplets I
2909Minimum Sum of Mountain Triplets II
2921Maximum Profitable Triplets With Increasing Prices II
2941Maximum GCD-Sum of a Subarray
2945Find Maximum Non-decreasing Array Length
2947Count Beautiful Substrings I
2949Count Beautiful Substrings II
2950Number of Divisible Substrings
2955Number of Same-End Substrings
2968Apply Operations to Maximize Frequency Score
2971Find Polygon With the Largest Perimeter
2983Palindrome Rearrangement Queries
3003Maximize the Number of Partitions After Operations
3015Count the Number of Houses at a Certain Distance I
3017Count the Number of Houses at a Certain Distance II
3026Maximum Good Subarray Sum
3028Ant on the Boundary
3070Count Submatrices with Top-Left Element and Sum Less Than k
3073Maximum Increasing Triplet Value
3081Replace Question Marks in String to Minimize Its Value
3086Minimum Moves to Pick K Ones
3096Minimum Levels to Gain More Points
3098Find the Sum of Subsequence Powers
3152Special Array II
3153Sum of Digit Differences of All Pairs
3179Find the N-th Value After K Seconds
3189Minimum Moves to Get a Peaceful Board
3197Find the Minimum Area to Cover All Ones II
3205Maximum Array Hopping Score I
3221Maximum Array Hopping Score II
3224Minimum Array Changes to Make Differences Equal
3225Maximum Score From Grid Operations
3250Find the Count of Monotonic Pairs I
3251Find the Count of Monotonic Pairs II
3261Count Substrings That Satisfy K-Constraint II
3287Find the Maximum Sequence Value of Array
3299Sum of Consecutive Subsequences
3312Sorted GCD Pair Queries
3323Minimize Connected Groups by Inserting Interval
3334Find the Maximum Factor Score of Array
3348Smallest Divisible Digit Product II
3354Make Array Elements Equal to Zero
3361Shift Distance Between Two Strings
3364Minimum Positive Sum Subarray
3372Maximize the Number of Target Nodes After Connecting Trees I
3381Maximum Subarray Sum With Length Divisible by K
3395Subsequences with a Unique Middle Mode I
3410Maximize Subarray Sum After Removing All Occurrences of One Element
3416Subsequences with a Unique Middle Mode II
3425Longest Special Path
3432Count Partitions with Even Sum Difference
3445Maximum Difference Between Even and Odd Frequency II
3473Sum of K Subarrays With Length at Least M
3485Longest Common Prefix of K Strings After Removal
3486Longest Special Path II
3494Find the Minimum Amount of Time to Brew Potions
3500Minimum Cost to Divide Array Into Subarrays
3502Minimum Cost to Reach Every Position
3511Make a Positive Array
3532Path Existence Queries in a Graph I
3534Path Existence Queries in a Graph II
3538Merge Operations for Minimum Travel Time
3540Minimum Time to Visit All Houses
3578Count Partitions With Max-Min Difference at Most K
3585Find Weighted Median Node in Tree
3598Longest Common Prefix Between Adjacent Strings After Removals
3599Partition Array to Minimize XOR
3628Maximum Number of Subsequences After One Inserting
3632Subarrays with XOR at Least K
3651Minimum Cost Path with Teleportations
3654Minimum Sum After Divisible Sum Deletions
3656Determine if a Simple Graph Exists
3660Jump Game IX
3707Equal Score Substrings
3709Design Exam Scores Tracker
3714Longest Balanced Substring II
3719Longest Balanced Subarray I
3721Longest Balanced Subarray II
3728Stable Subarrays With Equal Boundary and Interior Sum
3729Count Distinct Subarrays Divisible by K in Sorted Array
3737Count Subarrays With Majority Element I
3738Longest Non-Decreasing Subarray After Replacing at Most One Element
3739Count Subarrays With Majority Element II
3748Count Stable Subarrays
3755Find Maximum Balanced XOR Subarray Length
3756Concatenate Non-Zero Digits and Multiply by Sum II
3762Minimum Operations to Equalize Subarrays
3765Complete Prime Number
3771Total Score of Dungeon Runs
3788Maximum Score of a Split
3802Number of Ways to Paint Sheets
3814Maximum Capacity Within Budget
3826Minimum Partition Score
3830Longest Alternating Subarray After Removing At Most One Element
3845Maximum Subarray XOR with Bounded Range
3862Find the Smallest Balanced Index
3864Minimum Cost to Partition a Binary String
3867Sum of GCD of Formed Pairs
3883Count Non Decreasing Arrays With Given Digit Sums
3886Sum of Sortable Integers
3903Smallest Stable Index I
3904Smallest Stable Index II
3911K-th Smallest Remaining Even Integer in Subarray Queries
3912Valid Elements in an Array
3916Number of ZigZag Arrays III
3918Sum of Primes Between Number and Its Reverse
3919Minimum Cost to Move Between Indices
3929Minimum Partition Score II
3948Lexicographically Maximum MEX Array
3956Maximum Sum of M Non-Overlapping Subarrays I
3957Maximum Sum of M Non-Overlapping Subarrays II
3962Maximum Subarray Sum After at Most K Swaps
3966Count Good Integers in a Range
3969Valid Subarrays With Matching Sum Digits I
3972Valid Subarrays With Matching Sum Digits II
3979Maximum Valid Pair Sum
3981Count Distinct Ways to Form Target from Two Strings
3984Divisible Game
3985Palindromic Subarray Sum
3989Maximum Consistent Columns in a Grid