Question bank › Dynamic Programming
Dsa Dynamic Programming Easy

Gallery Guard Placement

An art gallery has a long hallway with N paintings in a row. Each painting i has a value V[i]. You must place guards such that every painting is 'protected'. A guard placed at painting i protects paintings i-1, i, and i+1. Placing a guard at painting i costs an amount equal to the value V[i]. Find the minimum total cost to protect all N paintings. Input Format: Line 1: N Line 2: N space-separated integers representing the values of paintings. Output Format: A single integer representing the minimum cost. Example: Input: 3 10 20 30 Output: 20 Explanation: Placing a guard at index 1 (value 20) protects paintings at 0, 1, and 2.

Key concepts

dynamic_programmingoptimization

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.