Leetcode Problem 1422. Maximum Score After Splitting a String

1422. Maximum Score After Splitting a String

Leetcode Solutions

Count Left Zeros and Right Ones

  1. Initialize ones to the total count of '1's in s.
  2. Initialize zeros to 0 and max_score to 0.
  3. Iterate through the string s from the first character to the second-to-last character: a. If the current character is '1', decrement ones. b. If the current character is '0', increment zeros. c. Update max_score with the maximum of max_score and zeros + ones.
  4. Return max_score.
UML Thumbnail

Brute Force

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...