Dsa
Sliding Window
Medium
Max Sum of Non-Overlapping Subarrays
Given an array of integers, find the maximum sum of two non-overlapping subarrays, where each subarray has a minimum length of k. You need to return the maximum possible sum. Input consists of a single line containing an integer n (1 <= n <= 10^5), followed by n integers. The last integer is k (1 <= k <= n). Output the maximum sum of two non-overlapping subarrays of at least length k.
Example:
Input:
8 1 2 1 3 4 5 2 1 3
2
Output:
12
Key concepts
sliding_windowarrayssubarrays
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now