Function to count maximum number of occurrences of s2 as subsequence in s1 by concatenating s1 , n1 times and s2 , n2 times
function getMaxRepetitions ( s1 , n1 , s2 , n2 ) { let temp1 = new Array ( 26 ) ; let temp2 = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) { temp1 [ i ] = 0 ; temp2 [ i ] = 0 ; } for ( let i = 0 ; i < s1 . split ( " " ) . length ; i ++ ) temp1 [ s1 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( let i = 0 ; i < s2 . split ( " " ) . length ; i ++ ) temp2 [ s2 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( temp2 [ i ] > temp1 [ i ] ) return 0 ; }