Java solution
\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        int idx = ruleKey.equals("color") ? 1 : r
```\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        int idx = ruleKey.equals("color") ? 1 : ruleKey.equals("name") ? 2 : 0;\n        \n        int ans = 0;\n        for (List<String> item : items) {\n            if (item.get(idx).equals(ruleValue)) {\n                ans++;\n            }\n        }\n        \n        return ans;\n    }\n}\n```
[]