mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-25 20:21:47 +08:00
规范格式
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
package leetcode
|
||||
|
||||
func findRestaurant(list1 []string, list2 []string) []string {
|
||||
m, ans := make(map[string]int, len(list1)), []string{}
|
||||
for i, r := range list1 {
|
||||
m[r] = i
|
||||
}
|
||||
for j, r := range list2 {
|
||||
if _, ok := m[r]; ok {
|
||||
m[r] += j
|
||||
if len(ans) == 0 || m[r] == m[ans[0]] {
|
||||
ans = append(ans, r)
|
||||
} else if m[r] < m[ans[0]] {
|
||||
ans = []string{r}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
Reference in New Issue
Block a user