aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-12-22 16:13:52 +0000
committerterminaldweller <devi@terminaldweller.com>2023-12-22 16:13:52 +0000
commit3b9d979d1266a00e2a08f8d698b28a2dabdd761b (patch)
tree638f54a32d032bdd017466c280d1cb51510849e0
parent1637 (diff)
downloadleetcode-3b9d979d1266a00e2a08f8d698b28a2dabdd761b.tar.gz
leetcode-3b9d979d1266a00e2a08f8d698b28a2dabdd761b.zip
1422
-rwxr-xr-x1422/main.py23
1 files changed, 23 insertions, 0 deletions
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()