diff options
author | terminaldweller <devi@terminaldweller.com> | 2023-12-27 22:05:50 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2023-12-27 22:05:50 +0000 |
commit | bde32595f8e5fd91d125ac774f29d11c2c3ef234 (patch) | |
tree | a428dd71022d6b2e2c4094f34ceb09d9bea7bd6e /1578/main.py | |
parent | 1155 (diff) | |
download | leetcode-bde32595f8e5fd91d125ac774f29d11c2c3ef234.tar.gz leetcode-bde32595f8e5fd91d125ac774f29d11c2c3ef234.zip |
1578
Diffstat (limited to '1578/main.py')
-rwxr-xr-x | 1578/main.py | 23 |
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() |