Search
⌘K

Leetcode 2841. Maximum Sum of Almost Unique Subarray

Find the maximum sum of any contiguous subarray of length k that contains at least m distinct elements (return 0 if none). This is a sliding-window problem where you maintain the window sum and a frequency map to track distinct counts efficiently.


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.