Question bank › Sliding Window
Dsa Sliding Window Easy

Maximize Consecutive Revenue

You are given an array of integers `revenue` representing daily revenues of a business over a period. Your task is to find the maximum total revenue you can obtain from any contiguous subarray of daily revenues, considering at most `k` days with negative revenue can be included in your subarray. Return this maximum total revenue. Input Format: - The first line contains an integer `n`, the number of elements in the `revenue` array. - The second line contains an integer `k`, the maximum number of negative revenues allowed in the subarray. - The third line contains `n` integers, the daily revenues. Output Format: - Output the maximum total revenue as an integer. Example: Input: 6 2 1 -2 3 4 -1 2 Output: 10

Key concepts

sliding_windowarraymax_profit

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.