mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-12 18:08:38 +08:00
251103
This commit is contained in:
18
25/11/go/1578.go
Normal file
18
25/11/go/1578.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package A
|
||||
|
||||
func minCost(colors string, neededTime []int) int {
|
||||
count := 0
|
||||
ans := 0
|
||||
m := 0
|
||||
for i := 0; i < len(colors); i++ {
|
||||
count += neededTime[i]
|
||||
m = max(m, neededTime[i])
|
||||
if i != len(colors)-1 && colors[i] == colors[i+1] {
|
||||
continue
|
||||
}
|
||||
ans += count - m
|
||||
m = 0
|
||||
count = 0
|
||||
}
|
||||
return ans
|
||||
}
|
||||
Reference in New Issue
Block a user