Search
⌘K

Leetcode 3026. Maximum Good Subarray Sum

Find a contiguous subarray whose first and last elements differ by exactly k and return the maximum possible subarray sum (or 0 if none). With n up to 1e5, the typical O(n) approach scans the array using prefix sums and a map that remembers the best starting prefix for each value to evaluate candidate ends.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.