func countMatches(items [][]string, ruleKey string, ruleValue string) int {
m := map[string]int{
"type": 0,
"color": 1,
"name": 2,
}
var count int
idx := m[ruleKey]
for _, v := range items {
if v[idx] == ruleValue {
count++
}
}
return count
}
每日一题|2022-10-29|1773. 统计匹配检索规则的物品数量|Golang
最新推荐文章于 2024-07-19 15:43:42 发布