Minimum Time to Make Rope Colorful Problem

Minimum Time to Make Rope Colorful Problem — ExecCode Easy DSA Practice

Solve the Minimum Time to Make Rope Colorful problem on ExecCode. Free online easy DSA practice in Sort. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a 0-indexed string colors where colors[i] is the color of the i^th balloon. Your task is to compute the required answer and return the minimum time Bob needs to make the rope colorful . Alice has n balloons arranged on a rope. Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful.

Examples

Input {"colors": "abaac", "neededTime": [1, 2, 3, 4, 5]}; Output 3. Input {"colors": "aabaa", "neededTime": [1, 2, 3, 4, 1]}; Output 2. Input {"colors": "abc", "neededTime": [1, 2, 3]}; Output 0

Constraints

n == colors.length == neededTime.length 1 <= n <= 10^5 1 <= neededTime[i] <= 10^4 colors contains only lowercase English letters.

Practice Minimum Time to Make Rope Colorful free on ExecCode. Browse DSA problems, topic map, and placement guides.