Write a function to solve a string manipulation or array-based algorithmic problem on a platform like CoderPad or HackerRank.
For this implementation, return the length of the longest substring containing no repeated characters. The substring must be contiguous, and an empty input returns 0.
Function: def longest_unique_substring(s):
Input: A string s.
Output: An integer representing the maximum length.
def longest_unique_substring(s):