You're at index 0 of an array nums. From index , you can jump to any index where . Your score is the sum of all visited elements. Find the maximum score to reach the last index.
Example: nums = [1, -1, -2, 4, -7, 3], k = 2. One optimal path: 0 → 2 → 4 → 5 with score . Wait, that's not right. Let me reconsider: 0 → 1 → 3 → 5 with score . This is where DP meets monotonic queues. The naive DP is . Can you see the sliding window structure?