Problem
Given an array nums and an integer k, consider every subarray of length `k` whose elements are all distinct. Return the largest sum among them, or 0 if no such subarray exists.
Example 1
- Input
- nums = [1, 5, 4, 2, 9, 9, 9], k = 3
- Output
- 15
- Why
- [5, 4, 2] = 11, [4, 2, 9] = 15
Example 2
- Input
- nums = [4, 4, 4], k = 3
- Output
- 0
Constraints
1 <= k <= nums.length <= 10^51 <= nums[i] <= 10^5