Solve a common coding problem, such as finding the longest substring without repeating characters.
Implement length_of_longest_substring(s), which returns the length of the longest substring containing no repeated characters. The input is a string, and the output is an integer. Aim for an O(n) solution using a sliding window.
def length_of_longest_substring(s):