Given a string s, return the length of the longest substring without repeating characters. Explain and implement an O(n) sliding-window solution using a hash map or set. Discuss time and space complexity, and note any changes needed to correctly handle Unicode characters.