Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Make Rope Colorful

Minimum Time to Make Rope Colorful gives a color string and removal time for each balloon. Remove balloons so adjacent balloons differ in color, then return the least total time.

Statement

You are given a string colors of length n, where colors[i] represents the color of the balloon at index i on a rope, and an integer array neededTime of length n, where neededTime[i] represents the time required to remove the balloon at index i from the rope.

The rope is colorful if no two adjacent balloons share the same color. Bob can remove balloons from the rope to achieve this configuration.

Return the minimum total time required to make the rope colorful.

Constraints:

  • n ==== colors.length ==== neededTime.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq neededTime[i] ≤104\leq 10^4

  • colors contains only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Make Rope Colorful

Minimum Time to Make Rope Colorful gives a color string and removal time for each balloon. Remove balloons so adjacent balloons differ in color, then return the least total time.

Statement

You are given a string colors of length n, where colors[i] represents the color of the balloon at index i on a rope, and an integer array neededTime of length n, where neededTime[i] represents the time required to remove the balloon at index i from the rope.

The rope is colorful if no two adjacent balloons share the same color. Bob can remove balloons from the rope to achieve this configuration.

Return the minimum total time required to make the rope colorful.

Constraints:

  • n ==== colors.length ==== neededTime.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq neededTime[i] ≤104\leq 10^4

  • colors contains only lowercase English letters.