From b901dc4b92a9cce4e3959a508b91dfc119ce97d0 Mon Sep 17 00:00:00 2001 From: Aykhan Shahsuvarov Date: Fri, 22 Dec 2023 23:55:52 +0400 Subject: [PATCH] Added max_score --- accepted/easy.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/accepted/easy.py b/accepted/easy.py index d31de04..e2d8cbd 100644 --- a/accepted/easy.py +++ b/accepted/easy.py @@ -67,4 +67,16 @@ class AcceptedEasy: x2 //= 10 reverse_x //= 10 - return reverse_x == x \ No newline at end of file + return reverse_x == x + +def max_score(s: str) -> int: + """ + Link: https://leetcode.com/problems/maximum-score-after-splitting-a-string/ + Runtime: 47 ms + """ + m_score = 0 + for i in range(1, len(s)): + score = s[:i].count('0') + s[i:].count('1') + if s[:i].count('0') + s[i:].count('1') > m_score: + m_score = score + return m_score