cswork / OA打开练习工作台

YahooOA #2

Count Binary Substrings

估计简单可在线判题

考点(AI 标注)字符串双指针滑窗

Count substrings consisting of two adjacent equal-length runs of consecutive 0s and 1s, counting each position separately.

See "Input" for the standard input/output conventions and constraints added by this site.

输入格式

A binary string of length 1..100000.

输出格式

Output the number of valid substrings.

样例 1

输入:

011001

输出:

4

样例 2

输入:

0011

输出:

2

样例 3

输入:

10101

输出:

4

样例 4

输入:

000111

输出:

3