input: Write a python function to find the longest substring in a given string.
  assert longest_substring("abcabcbb") == "abc"
  assert longest_substring("bbbbb") == "b"
  assert longest_substring("pwwkew") == "wke"
  assert longest_substring(" ") == " "
  assert longest_substring("dvdf") == "vdf"
output: def longest_substring(s):
      char_map = {}
      start = 0
      max_length = 0
      max_substring = ""
      
      for end in range(len(s)):
          if s[end] in char_map:
              start = max(start, char_map[s[end]] + 1)
          char_map[s[end]] = end
          if end - start + 1 > max_length:
              max_length = end - start + 1
              max_substring = s[start:end+1]
      
      return max_substring