Count the Transitions
Count positions where a binary string switches between 0 and 1 (adjacent unequal characters).
Input: one line with a binary string.
Output: the number of transitions.
Constraints:
- 1 ≤ |S| ≤ 105
Sample Tests
Input 1
00110
Output 1
2
Input 2
1111
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.