Increase the count in array if a character is found
for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ count [ ord ( $ str [ $ i ] ) ] ++ ; $ max_distinct = 0 ; for ( $ i = 0 ; $ i < $ NO_OF_CHARS ; $ i ++ ) if ( $ count [ $ i ] != 0 ) $ max_distinct ++ ; return $ max_distinct ; } function smallesteSubstr_maxDistictChar ( $ str ) {