CPP code to find number of subsequences of " ab " in the string S which is repeated K times .
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countOccurrences ( string s , int K ) { int n = s . length ( ) ; int C , c1 = 0 , c2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' a ' )