Prefix Sum | LeetCode Problems

132 Prefix Sum solutions to LeetCode solutions.

Prefix Sum Problems View all solutions →

Minimum Size Subarray Sum

#209 Medium

Product of Array Except Self

#238 Medium

Range Sum Query - Immutable

#303 Easy

Range Sum Query 2D - Immutable

#304 Medium

Max Sum of Rectangle No Larger Than K

#363 Hard

Split Array Largest Sum

#410 Hard

Random Point in Non-overlapping Rectangles

#497 Medium

Continuous Subarray Sum

#523 Medium

Contiguous Array

#525 Medium

Random Pick with Weight

#528 Medium

Subarray Sum Equals K

#560 Medium

Maximum Sum of 3 Non-Overlapping Subarrays

#689 Hard

Subarray Product Less Than K

#713 Medium

Find Pivot Index

#724 Easy

My Calendar II

#731 Medium

My Calendar III

#732 Hard

Smallest Rotation with Highest Score

#798 Hard

Largest Sum of Averages

#813 Medium

Shifting Letters

#848 Medium

Shortest Subarray with Sum at Least K

#862 Hard

Valid Permutations for DI Sequence

#903 Hard

Binary Subarrays With Sum

#930 Medium

Subarray Sums Divisible by K

#974 Medium

Minimum Number of K Consecutive Bit Flips

#995 Hard

Minimum Cost to Merge Stones

#1000 Hard

Max Consecutive Ones III

#1004 Medium

Number of Submatrices That Sum to Target

#1074 Hard

Car Pooling

#1094 Medium

Corporate Flight Bookings

#1109 Medium

Longest Well-Performing Interval

#1124 Medium

Stone Game II

#1140 Medium

Can Make Palindrome from Substring

#1177 Medium

Get Equal Substrings Within Budget

#1208 Medium

Count Number of Nice Subarrays

#1248 Medium

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

#1292 Medium

XOR Queries of a Subarray

#1310 Medium

Matrix Block Sum

#1314 Medium

Product of the Last K Numbers

#1352 Medium

Find the Longest Substring Containing Vowels in Even Counts

#1371 Medium

Minimum Value to Get Positive Step by Step Sum

#1413 Easy

Build Array Where You Can Find The Maximum Exactly K Comparisons

#1420 Hard

Maximum Score After Splitting a String

#1422 Easy

Maximum Points You Can Obtain from Cards

#1423 Medium

Count Triplets That Can Form Two Arrays of Equal XOR

#1442 Medium

Number of Ways of Cutting a Pizza

#1444 Hard

Running Sum of 1d Array

#1480 Easy

Range Sum of Sorted Subarray Sums

#1508 Medium

Number of Sub-arrays With Odd Sum

#1524 Medium

Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

#1546 Medium

Sum of All Odd Length Subarrays

#1588 Easy

Maximum Sum Obtained of Any Permutation

#1589 Medium

Make Sum Divisible by P

#1590 Medium

Minimum Operations to Reduce X to Zero

#1658 Medium

Ways to Make a Fair Array

#1664 Medium

Minimum Moves to Make Array Complementary

#1674 Medium

Sum of Absolute Differences in a Sorted Array

#1685 Medium

Delivering Boxes from Storage to Ports

#1687 Hard

Minimum Adjacent Swaps for K Consecutive Ones

#1703 Hard

Ways to Split Array Into Three Subarrays

#1712 Medium

Find the Highest Altitude

#1732 Easy

Change Minimum Characters to Satisfy One of Three Conditions

#1737 Medium

Find Kth Largest XOR Coordinate Value

#1738 Medium

Can You Eat Your Favorite Candy on Your Favorite Day?

#1744 Medium

Minimum Number of Operations to Move All Balls to Each Box

#1769 Medium

Maximum XOR for Each Query

#1829 Medium

Frequency of the Most Frequent Element

#1838 Medium

Maximum Population Year

#1854 Easy

Maximum Subarray Min-Product

#1856 Medium

Sum of Floored Pairs

#1862 Hard

Jump Game VII

#1871 Medium

Stone Game VIII

#1872 Hard

Get Biggest Three Rhombus Sums in a Grid

#1878 Medium

Minimum Space Wasted From Packaging

#1889 Hard

Check if All the Integers in a Range Are Covered

#1893 Easy

Find the Student that Will Replace the Chalk

#1894 Medium

Largest Magic Square

#1895 Medium

Number of Wonderful Substrings

#1915 Medium

Unique Length-3 Palindromic Subsequences

#1930 Medium

Describe the Painting

#1943 Medium

Find the Middle Index in Array

#1991 Easy

Grid Game

#2017 Medium

Maximize the Confusion of an Exam

#2024 Medium

Maximum Number of Ways to Partition an Array

#2025 Hard

Plates Between Candles

#2055 Medium

Find Good Days to Rob the Bank

#2100 Medium

Maximum Fruits Harvested After at Most K Steps

#2106 Hard

Intervals Between Identical Elements

#2121 Medium

Stamping the Grid

#2132 Hard

Count the Hidden Sequences

#2145 Medium

Removing Minimum Number of Magic Beans

#2171 Medium

Maximize Number of Subsequences in a String

#2207 Medium

Minimum White Tiles After Covering With Carpets

#2209 Hard

Maximum Value of K Coins From Piles

#2218 Hard

Number of Ways to Select Buildings

#2222 Medium

Maximum Total Beauty of the Gardens

#2234 Hard

Maximum Trailing Zeros in a Cornered Path

#2245 Medium

Number of Flowers in Full Bloom

#2251 Hard

Minimum Average Difference

#2256 Medium

Number of Ways to Split Array

#2270 Medium

Maximum White Tiles Covered by a Carpet

#2271 Medium

Count Subarrays With Score Less Than K

#2302 Hard

Shifting Letters II

#2381 Medium

Maximum Segment Sum After Removals

#2382 Hard

Longest Subsequence With Limited Sum

#2389 Easy

Minimum Amount of Time to Collect Garbage

#2391 Medium

Find All Good Indices

#2420 Medium

Maximum Sum of an Hourglass

#2428 Medium

Range Product Queries of Powers

#2438 Medium

Minimize Maximum of Array

#2439 Medium

Minimum Cost to Make Array Equal

#2448 Hard

Minimum Penalty for a Shop

#2483 Medium

Find the Pivot Integer

#2485 Easy

Count Subarrays With Median K

#2488 Hard

Increment Submatrices by One

#2536 Medium

Count Vowel Strings in Ranges

#2559 Medium

Left and Right Sum Differences

#2574 Easy

Rearrange Array to Maximize Prefix Score

#2587 Medium

Count the Number of Beautiful Subarrays

#2588 Medium

Sum of Distances

#2615 Medium

Find the Score of All Prefixes of an Array

#2640 Medium

Maximum OR

#2680 Medium

Count of Interesting Subarrays

#2845 Medium

Points That Intersect With Cars

#2848 Easy

Count Beautiful Substrings I

#2947 Medium

Find Polygon With the Largest Perimeter

#2971 Medium

Count the Number of Houses at a Certain Distance I

#3015 Medium

Ant on the Boundary

#3028 Easy

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

#3070 Medium

Minimum Operations to Make Binary Array Elements Equal to One I

#3191 Medium

Zero Array Transformation I

#3355 Medium

Zero Array Transformation II

#3356 Medium

Zero Array Transformation III

#3362 Medium