input: Write a function to find the longest common substring in two strings. The function should take two strings as input and return the longest common substring. If there are multiple longest common substrings, return any one of them. If there is no common substring, return an empty string.
  
  assert longestCommonSubstring("ABCDEFG", "BCDXYZ") == "BCD"
  assert longestCommonSubstring("HelloWorld", "Wor") == "Wor"
  assert longestCommonSubstring("Python", "Java") == ""
  assert longestCommonSubstring("Longest", "TestLong") == "Long"
  assert longestCommonSubstring("", "NonEmpty") == ""
  assert longestCommonSubstring("SameString", "SameString") == "SameString"
output: def longestCommonSubstring(str1, str2):
      m, n = len(str1), len(str2)
      maxLength = 0
      endIndex = 0
      dp = [[0] * (n + 1) for _ in range(m + 1)]
      
      for i in range(1, m + 1):
          for j in range(1, n + 1):
              if str1[i - 1] == str2[j - 1]:
                  dp[i][j] = dp[i - 1][j - 1] + 1
                  if dp[i][j] > maxLength:
                      maxLength = dp[i][j]
                      endIndex = i
      
      return str1[endIndex - maxLength:endIndex]