If sum of adjacent characters is not K and the flag variable is set , end the substring here
if ( flag == 1 && ( s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + s [ i + 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) != k ) {