Question bank › Sliding Window
Dsa Sliding Window Easy

Rotate Subarray to Maximize Sum

Given an array of integers and an integer K, determine the maximum sum of the array after rotating any contiguous subarray of size K. The rotation means moving the first K elements to the end of the array. Input: - The first line contains an integer N (1 <= N <= 10^5) - the number of elements in the array. - The second line contains N space-separated integers representing the array elements. - The third line contains the integer K (1 <= K <= N). Output: - Output a single integer representing the maximum possible sum of the array after one rotation of a subarray of size K. Example: Input: 5 1 2 3 4 5 3 Output: 15

Key concepts

sliding_windowarrayrotation

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.