思路:
字符串匹配
1.首先获得的第一个字符串是第一个检索规则 是索引数量
2.第二个获得的字符串是字符串匹配的内容
这个题目主要是给出的数组类型是泛型list,读取数组的方法和二维数组不同
class Solution {
public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {
int sum=0;//计算符合规则的数量
int len1=items.size();
int m=0;
if(ruleKey.equals("type"))
{
m=0;
}
else if(ruleKey.equals("color"))
{
m=1;
}
else
{
m=2;
}
for(int i=0;i<len1;i++)
{
if(items.get(i).get(m).equals(ruleValue))
{
sum++;
}
}
return sum;
}
}