From 3b9d979d1266a00e2a08f8d698b28a2dabdd761b Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Fri, 22 Dec 2023 11:13:52 -0500 Subject: 1422 --- 1422/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 1422/main.py diff --git a/1422/main.py b/1422/main.py new file mode 100755 index 0000000..faf01ea --- /dev/null +++ b/1422/main.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + + +class Solution: + def maxScore(self, s: str) -> int: + max_score = 0 + for i in range(1, len(s)): + left = s[:i] + right = s[i:] + score = left.count("0") + right.count("1") + if score > max_score: + max_score = score + return max_score + + +def main(): + solution = Solution() + s = "011101" + print(solution.maxScore(s)) + + +if __name__ == "__main__": + main() -- cgit v1.2.3