insidcode
ProblemsDuelLeaderboardStats
Sign In
  1. Home
  2. Problems
  3. Find the maximum sum of any contiguous subarray of size k (Fixed-size sliding window).

Find the maximum sum of any contiguous subarray of size k (Fixed-size sliding window).

Difficulty: Medium

Phase: 6 · Mixed Logical Challenges

XP Reward: 20 XP

Topics: Mixed Logical Challenges, Medium

Supported Languages: Python, JavaScript, C, C++, Java

Problem Description

Given N integers on line 2 and K on line 3, find maximum sum of any contiguous subarray of size K. Input Format: Read input from standard input (stdin). Output Format: Print the result to standard output (stdout).

Constraints

  • -10^9 <= N <= 10^9

Examples

Example 1

Input: 6 2 1 5 1 3 2 3

Output: 9

Explanation: Sample execution for input 6 2 1 5 1 3 2 3