values and an integer width. Consider every contiguous stretch of the array of length exactly width in which **all numbers are different**.
Return the largest sum among those stretches. If no stretch qualifies, return 0.
Aim for a single pass over the array.values=[3, 7, 2, 7, 5, 1], width=3 → 14
Windows of length 3: [3, 7, 2] sums to 12, [7, 2, 7] has a repeat, [2, 7, 5] sums to 14, [7, 5, 1] sums to 13. The best is 14.
values=[6, 6, 6, 6], width=2 → 0
Every window holds two 6s, so no window qualifies and the answer is 0.
values=[4, 9, 1], width=1 → 9
values=[3, 7, 2, 7, 5, 1], width=3
14
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.