Write a function to solve a common algorithmic problem using Python.
Implement length_of_longest_substring(s) to return the length of the longest contiguous substring containing no repeated characters. The input is a string, and the output is an integer.
Examples: s = "abcabcbb" returns 3 because "abc" is the longest valid substring. s = "bbbbb" returns 1.
Constraints: 0 <= len(s) <= 10^5; s may contain letters, digits, symbols, and spaces.
def length_of_longest_substring(s):