aboutsummaryrefslogtreecommitdiffstats
path: root/1578/main.py
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-12-27 22:05:50 +0000
committerterminaldweller <devi@terminaldweller.com>2023-12-27 22:05:50 +0000
commitbde32595f8e5fd91d125ac774f29d11c2c3ef234 (patch)
treea428dd71022d6b2e2c4094f34ceb09d9bea7bd6e /1578/main.py
parent1155 (diff)
downloadleetcode-bde32595f8e5fd91d125ac774f29d11c2c3ef234.tar.gz
leetcode-bde32595f8e5fd91d125ac774f29d11c2c3ef234.zip
1578
Diffstat (limited to '1578/main.py')
-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()