From bde32595f8e5fd91d125ac774f29d11c2c3ef234 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 27 Dec 2023 17:05:50 -0500 Subject: 1578 --- 1578/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 1578/main.py (limited to '1578') 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() -- cgit v1.2.3