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, a left substring and a 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.
Example 1
Input
s = "011101"Output
5All possible non-empty splits have scores 5, 4, 3, 2, and 3, so the maximum score is 5.
Example 2
Input
s = "00111"Output
5When left = "00" and right = "111", the score is 2 + 3 = 5, which is maximum.
Constraints
- 2 <= s.length <= 500
- The string
sconsists of characters'0'and'1'only.