Longest substring with two distinct improved