Question bank › Dynamic Programming
Dsa Dynamic Programming Easy

Server Cooling Protocol

A server processes requests every hour for N hours. For each hour i, there is a profit P[i]. However, the server has a physical limit: it can work for at most 3 consecutive hours before it MUST shut down for at least 1 hour to cool down. Find the maximum total profit you can achieve. Input Format: The first line contains an integer N. The second line contains N space-separated integers representing the profit P[i] for each hour. Output Format: A single integer representing the maximum possible profit. Example: Input: 5 10 10 10 10 100 Output: 130 Explanation: Work hours 1, 2, 3 (profit 30), skip hour 4, work hour 5 (profit 100). Total = 130.

Key concepts

dynamic_programminglinear_dp

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.