Remove characters from the beginning of sliding window having count more than 1 to minimize length .
if ( distEle == k ) : NEW_LINE INDENT while ( st < end and cnt [ ord ( str [ st ] ) - ord ( ' a ' ) ] > 1 ) : NEW_LINE INDENT cnt [ ord ( str [ st ] ) - ord ( ' a ' ) ] -= 1 NEW_LINE st += 1 NEW_LINE DEDENT DEDENT