2841. Maximum Sum of Almost Unique Subarray
You are given an integer array
nums
and two positive integersm
andk
.Return the maximum sum out of all almost unique subarrays of length
k
ofnums
. If no such subarray exists, return0
.A subarray of
nums
is almost unique if it contains at leastm
pairwise distinct elements.A subarray is a contiguous non-empty sequence of elements within an array.
1 | class Solution { |