Added max_score

This commit is contained in:
Aykhan Shahsuvarov 2023-12-22 23:55:52 +04:00
parent 876dff0e1c
commit b901dc4b92

View File

@ -67,4 +67,16 @@ class AcceptedEasy:
x2 //= 10
reverse_x //= 10
return reverse_x == x
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