给定两个数组的字符串 list1和 list2,找出最小索引总的共同字符串.一个共同字符串是 list1和 list2 两者中出现的字符串.一个最小索引总的共同字符串是共同字符串,如果它出现在 list1[i]和 list2[j] 中,那么 i + j 应该是所有其他共同字符串的最小值.返回所有最小索引总的共同字符串.返回任何顺序的答案.
To solve this problem, we can first create a dictionary to store the indices of each string in list1. Then, for each string in list2, we can check if it appears in the dictionary and calculate the index sum. If the index sum is smaller than the current minimum index sum, we update the result list. Here is the Python code to implement this algorithm:

```
def findRestaurant(list1, list2):
    index = {word: i for i, word in enumerate(list1)}
    min_sum = float('inf')
    result = []
    for j, word in enumerate(list2):
        if word in index:
            if j + index[word] < min_sum:
                min_sum = j + index[word]
                result = [word]
            elif j + index[word] == min_sum:
                result.append(word)
    return result
```

For example, if we have list1 = ["Shogun", "Tapioca Express", "Burger King", "KFC"], and list2 = ["KFC", "Shogun", "Burger King"], then the function would return ["Shogun"] because the index sum of "Shogun" is 1 + 1 = 2, which is the smallest among all common strings.