Tap here to switch tabs
Problem
Submissions

Problem: Minimum Changes To Make Alternating Binary String

Minimum Changes To Make Alternating Binary String asks you to change as few characters as possible so no two adjacent characters in the binary string are the same.

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

Minimum Changes To Make Alternating Binary String asks you to change as few characters as possible so no two adjacent characters in the binary string are the same.

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$'.