---
description: Easy
---

# 1422. Maximum Score After Splitting a String

Given a string `s` of zeros and ones, _return the maximum score after splitting the string into two **non-empty** substrings_ (i.e. **left** substring and **right** substring).\
The score after splitting a string is the number of **zeros** in the **left** substring plus the number of **ones** in the **right** substring.

## :innocent: [Solution](https://leetcode.com/problems/maximum-score-after-splitting-a-string/)

{% tabs %}
{% tab title="O(n2)" %}
```python
class Solution:
    def maxScore(self, s: str) -> int:
        
        max_score = 0
        for i in range(1,len(s)):
            score = s[:i].count('0') + s[i:].count('1')
            max_score = max(max_score,score)
        return max_score
```
{% endtab %}
{% endtabs %}
