aboutsummaryrefslogtreecommitdiffstats
path: root/1578/main.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x1578/main.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/1578/main.py b/1578/main.py
new file mode 100755
index 0000000..c4d2b3e
--- /dev/null
+++ b/1578/main.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import typing
+
+
+class Solution:
+ def minCost(self, colors: str, neededTime: typing.List[int]) -> int:
+ time = 0
+ n = len(colors)
+ for i in range(1, n):
+ if colors[i] == colors[i - 1]:
+ time += min(neededTime[i], neededTime[i - 1])
+ neededTime[i] = max(neededTime[i], neededTime[i - 1])
+ return time
+
+
+def main():
+ solution = Solution()
+ print(solution.minCost("abaa", [1, 2, 3, 4]))
+
+
+if __name__ == "__main__":
+ main()