1578. Minimum Time to Make Rope Colorful
Содержание
class Solution:
def minCost(self, colors: str, neededTime: List[int]) -> int:
res = i = 0
n = len(colors)
while i < n:
j = i
s = mx = 0
while j < n and colors[j] == colors[i]:
s += neededTime[j]
if mx < neededTime[j]:
mx = neededTime[j]
j += 1
if j - i > 1:
res += s - mx
i = j
return res