Minimum Time to Make Rope Colorful
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Balloons hang in a row on a rope. colors[i] is the color (a lowercase letter) of balloon i, and removing balloon i takes neededTime[i] seconds.
The rope is colorful when no two consecutive balloons have the same color. You may remove any balloons you like; equivalently, every maximal run of consecutive equal colors must be reduced to exactly one balloon.
Return the minimum total time needed to make the rope colorful.
Examples
Constraints
- n == colors.length == neededTime.length
- 1 <= n <= 10^5
- 1 <= neededTime[i] <= 10^4
- colors consists of lowercase English letters
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.