How would you approach finding the longest substring within a given string?
Implement the solution by returning the length of the longest substring that contains no repeated characters. The substring must be contiguous, and an empty input must return 0.
Input: A string s. Output: An integer representing the maximum valid substring length.
def longest_unique_substring(s):