Function to count maximum number of occurrences of s2 as subsequence in s1 by concatenating s1 , n1 times and s2 , n2 times
int getMaxRepetitions ( string s1 , int n1 , string s2 , int n2 ) { int temp1 [ 26 ] = { 0 } , temp2 [ 26 ] = { 0 } ; for ( char i : s1 ) temp1 [ i - ' a ' ] ++ ; for ( char i : s2 ) temp2 [ i - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( temp2 [ i ] > temp1 [ i ] ) return 0 ; }