cswork / OA打开练习工作台

SalesforceOA #10

Count Substrings

估计简单可在线判题

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

Count the contiguous substrings of the form 0^k1^k or 1^k0^k with k≥1. Substrings are counted by their start and end indices, so repeated content is counted separately; this is not every substring with equal numbers of 0s and 1s.

输入格式

One line containing a non-empty binary string. On this site the length is 1..200000.

输出格式

Output the number of qualifying substrings.

样例 1

输入:

10101

输出:

4

样例 2

输入:

00110011

输出:

6

样例 3

输入:

000

输出:

0

样例说明

The answers are 4, 6, and 0, respectively.