CT051
Tikki’s Tiffin Carousel
MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100
Chef Chutney’s lunch cart lines up its plates in a row. Find the greatest flavor score among every contiguous run of exactly k adjacent plates.
Input: n k, then n signed scores. Output: maximum sum of a contiguous length-k window (wrapping is not allowed).
Example 1:
Input: 5 2
4 -2 7 1 3
Output: 8
Example 2:
Input: 4 3
-5 -2 -8 -1
Output: -11
Example 3:
Input: 3 3
1 2 3
Output: 6
Constraints:
1≤k≤n≤200000; |score|≤10^9.