Company: DE Shaw

Difficulty: medium

Problem Statement

Count Binary Substrings Given a binary string `s`, count its non-empty contiguous substrings that contain the same number of `0`s and `1`s, and whose characters form exactly two consecutive groups. The groups may be `0`s followed by `1`s or `1`s followed by `0`s. Input One line containing the binary string `s`. Output Print the count. Constraints - `1 <= |s| <= 200000` - Every character of `s` is `0` or `1`. Example Input: `00110011` Output: `6` Notes Different occurrences are counted separately even if their text is equal.

More DE Shaw OA questionsInterview experiences