JAVA | 100% Efficient | Easy Solution
Upvote if it was helpful\n\n\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        \n\t\t//We ta
Upvote if it was helpful\n\n```\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        \n\t\t//We take an int variable to store the index of the rulekey value \n        int rk = -1;\n        if(ruleKey.equals("type"))\n            rk=0;\n        else if(ruleKey.equals("color"))\n            rk=1;\n        else\n            rk=2;\n        \n\t\t//Count variable is used to store the count of matching variables \n        int count = 0;\n        int len = items.size();\n        \n\t\t//We iterate over the list to count number of matching variables\n        for(int i=0;i<len;i++) {\n            if(items.get(i).get(rk).equals(ruleValue))\n                count++;\n        }\n        \n        return count;\n        \n    }\n}\n```
['Array', 'Java']