Start learning free

LESSON 215 OF 348 · PARTIAL SUMS #1

Maximum Sum Subarray of length K in Rust

Practice O(n * k)

Given an input array of integers and a positive integer k, find out the maximum sum of a contiguous subarray of length exactly k

Example

Input: nums = [5, 6, 1, 2, 6, 6, 4, 3], k = 3
Output: 4 6
Explanation: The subarray nums[4...6] has the maximum sum of 16
STEP 1 OF 6
    Ctrl + Enter to check

    Maximum Sum Subarray Of Length K in Rust

    Keep going with RustAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free