Brute force approach to find all substrings
for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { let subs = null ; if ( i < j ) subs = str . substring ( i , j ) ; else subs = str . substring ( j , i ) ; let subs_lenght = subs . length ; let sub_distinct_char = max_distinct_char ( subs , subs_lenght ) ;