Count ways to select three indices from Binary String with different adjacent digits
Improve Article
Save Article
Like Article
Improve Article
Save Article
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: Input: S = “00110”Output: 4Explanation: Below are the possible valid indices:=> {0, 2, 4} from “00110” forms “010”=> {0, 3, 4} from “00110” forms “010”=> {1, 2, 4} from “00110” forms “010”=> {1, 3, 4} from “00110”…