Update the map for the first substring
while ( right < len ) { if ( mp . has ( s [ right ] ) ) mp . set ( s [ right ] , mp . get ( s [ right ] ) + 1 ) else mp . set ( s [ right ] , 1 ) right ++ ; } if ( mp . size <= k ) return true ;