Minimum Index Sum of Two Lists – LeetCode 599
Problem
Description
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.
You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You could assume there always exists an answer.
Answer
Better
Code
1 | class Solution { |
思路
简单的利用hash表。时间复杂度$O(m+n)$,空间复杂度$O(m)$。
耗时$64$ ms,排名$2.89\%$
Better
思路
还没看到更好的思路