How to find the longest substring without duplicates in characters - Python solution