input: Write a function to find the longest common substring in two given strings. Return the longest common substring if found, otherwise return an empty string. If either of the strings is empty, return an empty string.
  assert longest_common_substring("Helwallomst", "Welcome")=="Hel"
  assert longest_common_substring("abcde", "cdeab")=="cde"
  assert longest_common_substring("hello", "world")==""
  assert longest_common_substring("python", "python")=="python"
  assert longest_common_substring("", "non-empty")==""
  assert longest_common_substring("non-empty", "")==""
output: def longest_common_substring(s1, s2):
      if not s1 or not s2:
          return ""
      m, n = len(s1), len(s2)
      dp = [[0] * (n + 1) for _ in range(m + 1)]
      max_len, end_index = 0, 0
      for i in range(1, m + 1):
          for j in range(1, n + 1):
              if s1[i - 1] == s2[j - 1]:
                  dp[i][j] = dp[i - 1][j - 1] + 1
                  if dp[i][j] > max_len:
                      max_len = dp[i][j]
                      end_index = i
      return s1[end_index - max_len:end_index]