A utility function to find longest common extension from index - L and index - R
function LCE ( str , n , L , R ) { let length = 0 ; while ( R + length < n && str [ L + length ] == str [ R + length ] ) length ++ ; return ( length ) ; }