Java | Easy | Optimal | Comments | 3ms
\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n      int result = 0;\n\t  \n\t  //find the index
```\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n      int result = 0;\n\t  \n\t  //find the index you need to check the lists for\n       int i = ruleKey.equals("type") ? 0 :ruleKey.equals("color") ? 1 : 2;\n\t   \n\t   //iterate through the input lists and increment result variable if rulevalue matches with the element at index\n        for(List<String> li : items){\n          if(li.get(i).equals(ruleValue)){\n            result++;\n          }\n        }\n\t\t\n\t\t//return result\n      return result;\n    }\n}\n```
['Java']