We have to check here both conditions together 1. substring ' s ▁ distinct ▁ characters ▁ is ▁ equal ▁ ▁ to ▁ maximum ▁ distinct ▁ characters ▁ ▁ 2 . ▁ substring ' s length should be minimum
if ( $ subs_lenght < $ minl && $ max_distinct == $ sub_distinct_char ) { $ minl = $ subs_lenght ; } } } return $ minl ; }