method which returns maximum length of substring
function answer ( A , n , k ) { let maxlen = 1 ; for ( let i = 0 ; i < 26 ; ++ i ) { maxlen = Math . max ( maxlen , findLen ( A , n , k , String . fromCharCode ( i + ' ' . charCodeAt ( 0 ) ) ) ) ; maxlen = Math . max ( maxlen , findLen ( A , n , k , String . fromCharCode ( i + ' ' . charCodeAt ( 0 ) ) ) ) ; } return maxlen ; }