Solved longest substring problem