Function to find the periodic string with minimum period
function findPeriodicString ( S ) { let l = 2 * S . length ; let count = 0 ; for ( let i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] == ' ' ) count ++ ; }