Medium · Strings
Minimum Time to Make Rope Colorful
Given a string colors and an array neededTime of the same length, where balloon i has color colors[i] and takes neededTime[i] to remove, return the minimum total time to remove balloons so that no two adjacent remaining balloons share a color.
Examples
Example 1
{
"colors": "aabaa",
"neededTime": [1, 2, 3, 4, 1]
}Output: min time = 2
Example 2
{
"colors": "abc",
"neededTime": [1, 2, 3]
}Output: min time = 0
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.