function to calculate the maximum length of substring of the form R ^ nK ^ n
function find ( s ) { let max = 0 , i , j = 0 , countk = 0 , countr = 0 ; let table = new Array ( s . length ) ; for ( let i = 0 ; i < s . length ; i ++ ) { table [ i ] = new Array ( 2 ) ; }