Tap here to switch tabs
Problem
Submissions

Problem: Minimum Changes To Make Alternating Binary String

med
30 min
Try to solve the Minimum Changes To Make Alternating Binary String problem.

Statement

You are given a binary string s. An operation consists of changing any character in s from '$0$' to '$1$' or from '$1$' to '$0$'.

A string is considered alternating if no two adjacent characters are identical.

Return the minimum number of operations needed to make s alternating.

Constraints:

  • 1≤1 \leq s.length ≤104\leq 10^4

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Changes To Make Alternating Binary String

med
30 min
Try to solve the Minimum Changes To Make Alternating Binary String problem.

Statement

You are given a binary string s. An operation consists of changing any character in s from '$0$' to '$1$' or from '$1$' to '$0$'.

A string is considered alternating if no two adjacent characters are identical.

Return the minimum number of operations needed to make s alternating.

Constraints:

  • 1≤1 \leq s.length ≤104\leq 10^4

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