Question bank › Sliding Window
Dsa Sliding Window Easy

Max Sum of Subarray of Size K

You are given an array of integers and a number k. Write a function to find the maximum sum of any contiguous subarray of size k. Input: - The first line contains an integer n (1 ≤ n ≤ 10^5): the size of the array. - The second line contains n integers a_i (−10^4 ≤ a_i ≤ 10^4), the elements of the array. - The third line contains an integer k (1 ≤ k ≤ n). Output: - An integer representing the maximum sum of the subarray of size k. Example: Input: 5 1 2 3 4 5 3 Output: 12

Key concepts

sliding_windowarraysummation

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.