Check if the current character can be added with previous substring to form the required substring
if ( i > 0 and ( ord ( p [ i - 1 ] ) != ( ( curr + 26 - 1 ) % 26 + ord ( ' a ' ) ) ) ) : NEW_LINE INDENT curLen = 0 NEW_LINE DEDENT