FunctionRacerProblemsRace

Maximum Score After Splitting a String

EasyStringsPython, JavaScript, TypeScript, Java, C++

s has only 0 and 1. Split it into two non-empty parts, a left and a right. The score of a split is the number of 0 in the left part plus the number of 1 in the right part. Return the highest score over all splits.

Example 1

s "011101"
returns 5

Splitting as 0 and 11101 gives 1 + 4 = 5.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems