Check if the current character can be added with previous substring to form the required substring
if ( i > 0 && ( p [ i - 1 ] . charCodeAt ( ) != ( ( curr + 26 - 1 ) % 26 + ' ' . charCodeAt ( ) ) ) ) { curLen = 0 ; }