Dsa
Dynamic Programming
Medium
String Decomposition Cost
You are given a string s and a valid decomposition cost function which is the sum of the lengths of the substrings that make up the same characters. Determine the minimum cost to decompose the string into valid substrings.
Input Format:
- A single line containing the string s.
Output Format:
- A single integer representing the minimum decomposition cost.
Example:
Input:
aabba
Output:
4
Key concepts
dynamic_programmingstringscost
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