Minimum Index Sum of Two Lists
利用哈希表统计字符排名就行
class Solution(object):
def findRestaurant(self, list1, list2):
"""
:type list1: List[str]
:type list2: List[str]
:rtype: List[str]
"""
tmp = collections.Counter()
for index, string in enumerate(list1):
tmp[string] = index
pri = sys.maxint
result = collections.defaultdict(list)
for index, string in enumerate(list2):
if string in tmp and tmp[string] + index <= pri:
pri = tmp[string] + index
result[pri].append(string)
return result[pri]