Tap here to switch tabs
Problem
Submissions

Problem: Flip String to Monotone Increasing

med
30 min
Try to solve the Flip String to Monotone Increasing problem.

Statement

Given a binary string s, you may flip any character in s from '0' to '1' or from '1' to '0'. Return the minimum number of flips needed to make s monotone increasing, meaning s can be written as some number of '0' characters followed by some number of '1' characters.

Note: A monotone increasing binary string has no '1' that appears before a '0'.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s[i] is either '0' or '1'

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Flip String to Monotone Increasing

med
30 min
Try to solve the Flip String to Monotone Increasing problem.

Statement

Given a binary string s, you may flip any character in s from '0' to '1' or from '1' to '0'. Return the minimum number of flips needed to make s monotone increasing, meaning s can be written as some number of '0' characters followed by some number of '1' characters.

Note: A monotone increasing binary string has no '1' that appears before a '0'.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s[i] is either '0' or '1'