Solve a mid-level LeetCode problem focusing on arrays or strings.
Implement the representative string problem below. Given a string s, return the length of the longest substring containing no repeated characters. A substring must contain contiguous characters, and the empty string is valid.
Use the function signature def length_of_longest_substring(s):. Return an integer. Aim for an efficient solution that processes the string in linear time.
def length_of_longest_substring(s):