Question bank › Dynamic Programming
Dsa Dynamic Programming Easy

Minimize Repair Costs

You are given an array of integers representing the costs of repairing segments of a road. The repair cost is given in the form of an array where the ith index represents the cost of repairing the ith segment. You want to determine the minimum total repair cost needed to repair all segments, but you have a special condition: you can skip repairing at most one segment. Your task is to compute the minimum total repair cost. Input format: The first line contains a single integer n (1 <= n <= 1000) - the number of segments. The second line contains n integers (1 <= costs[i] <= 10^4), where costs[i] represents the repair cost for the ith segment. Output format: Print the minimum total repair cost. Example: Input: 5 10 20 30 40 50 Output: 100

Key concepts

dynamic_programmingminimizationarray

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.