Remove characters from the beginning of sliding window having count more than 1 to minimize length .
if ( distEle == k ) { while ( st < end && cnt [ str [ st ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] > 1 ) { cnt [ str [ st ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] -- ; st ++ ; }