Question bank › Sliding Window
Dsa Sliding Window Easy

Product of Subarray Maximums

You are given an array of integers. Calculate the product of the maximum values of all contiguous subarrays of size 'k'. Return the sum of these products mod 10^9 + 7. Input: - The first line contains two integers, n (the length of the array) and k (the size of each subarray). - The second line contains n space-separated integers representing the elements of the array. Output: - Output a single integer representing the sum modulo 10^9 + 7. Example: Input: 5 3 1 2 3 4 5 Output: 18

Key concepts

sliding_windowarraysmath

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.