Tap here to switch tabs
Problem
Submissions

Problem: Minimum Flips to Make Binary String Coherent

Try to solve the Minimum Flips to Make Binary String Coherent problem.

Statement

You are given a binary string s. In a single operation, you can flip any character in s from '$0$' to '$1$' or from '$1$' to '$0$'.

A string is defined as coherent if it does not contain "$011$" or "$110$" as a subsequence.

Return the minimum number of flips required to make s coherent.

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: Minimum Flips to Make Binary String Coherent

Try to solve the Minimum Flips to Make Binary String Coherent problem.

Statement

You are given a binary string s. In a single operation, you can flip any character in s from '$0$' to '$1$' or from '$1$' to '$0$'.

A string is defined as coherent if it does not contain "$011$" or "$110$" as a subsequence.

Return the minimum number of flips required to make s coherent.

Constraints:

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

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