Prefix-Sum
LeetCode 2391: Minimum Amount of Time to Collect Garbage
·2 mins
LeetCode
Medium
Prefix-Sum
String
Array
LeetCode 2391 note: pickup time is the total garbage count; each truck only drives to the last house with its type, using a prefix sum of travel
Prefix Sum
·5 mins
Algorithm
Prefix-Sum
Introduction to Prefix Sum
LeetCode 724: Find Pivot Index
·2 mins
LeetCode
Daily
Easy
Prefix-Sum
LeetCode Problem Solving
LeetCode 560: Subarray Sum Equals K
·3 mins
LeetCode
Daily
Medium
Prefix-Sum
LeetCode Problem Solving
LeetCode 303: Range Sum Query - Immutable
·1 min
LeetCode
Easy
Prefix-Sum
LeetCode Problem Solving
LeetCode 1534: Count Good Triplets
·3 mins
LeetCode
Daily
Easy
Prefix-Sum
LeetCode Problem Solving
LeetCode 3494: Find the Minimum Amount of Time to Brew Potions
·2 mins
LeetCode
Medium
Simulation
Prefix-Sum
Array
LeetCode 3494 note: for each potion, push forward to get the last wizard’s finish time (everyone must be free), then subtract backward to get each wizard’s finish time
LeetCode 3070: Count Submatrices with Top-Left Element and Sum Less Than k
·2 mins
LeetCode
Medium
Array
Matrix
Prefix-Sum
LeetCode 3070 note: submatrices containing the top-left corner are exactly the 2D prefix sums P[i][j]; count those <= k
LeetCode 1991: Find the Middle Index in Array
·1 min
LeetCode
Easy
Array
Prefix-Sum
LeetCode 1991 note: compute the total, maintain the left sum while scanning, and get the right sum as total - left - nums[i]
LeetCode 1732: Find the Highest Altitude
·1 min
LeetCode
Easy
Array
Prefix-Sum
LeetCode 1732 note: the altitudes are prefix sums of gain starting from 0; take the maximum
LeetCode 1480: Running Sum of 1d Array
·1 min
LeetCode
Easy
Array
Prefix-Sum
LeetCode 1480 note: the definition of a prefix sum, adding each element to the previous running total
LeetCode 1413: Minimum Value to Get Positive Step by Step Sum
·1 min
LeetCode
Easy
Array
Prefix-Sum
LeetCode 1413 note: the start value plus every prefix sum must be at least 1, so it is max(1, 1 - minimum prefix sum)