Dsa
Dynamic Programming
Medium
Segment Covering Cost
You have a series of segments defined by their start and end points and a cost associated with each. Determine the minimum cost required to cover all segments such that each segment is included at least once.
Input Format:
- The first line contains an integer n (number of segments).
- Each of the next n lines contains three integers start, end, and cost.
Output Format:
- A single integer representing the minimum cost to cover all segments.
Example:
Input:
3
1 5 4
2 6 2
5 10 3
Output:
5
Key concepts
dynamic_programmingintervalscost_minimization
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