Tap here to switch tabs
Problem
Submissions

Problem: Count Valid Prefixes

Try to solve the Count Valid Prefixes problem.

Statement

Given a binary string s, return the total number of prefixes of s that can be rearranged to form an alternating binary string.

An alternating string is defined as a string where no two adjacent characters are identical.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists only of the characters ′0′'0' and ′1′'1'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Valid Prefixes

Try to solve the Count Valid Prefixes problem.

Statement

Given a binary string s, return the total number of prefixes of s that can be rearranged to form an alternating binary string.

An alternating string is defined as a string where no two adjacent characters are identical.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists only of the characters ′0′'0' and ′1′'1'.