Solve a programming logic question and explain your approach.
Implement length_of_longest_substring(s). Given a string s, return the length of its longest substring containing no repeated characters. The function must return an integer and treat every character, including spaces and symbols, as valid input.
def length_of_longest_substring(s):