a better implementation when reviewing the question [longest substring
without repeating characters], second try