![]() |
Given a binary string S of length N, the task is to find the number of ways to select three indices such that if they are arranged in increasing order of indices no two adjacent indices will have the same value. Examples:
An approach using the PrefixSum technique.
Follow the steps below to implement the above idea:
Below is the implementation of the above approach: C++
Java
Python3
C#
Javascript
Output
4 0 0 1 Time Complexity: O(N) Related Articles:
|
Reffered: https://www.geeksforgeeks.org
Strings |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 18 |