C++ Easy to understand for beginners
Since you only have to check one thing about each item (type, color or name) you determine the index of that and then scan the array with a for loop. \n\nYou ha
Since you only have to check one thing about each item (type, color or name) you determine the index of that and then scan the array with a for loop. \n\nYou have to keep track of the number of items that match the rule, so the sol varieble starts at 0 and you increment it by one everytime you see an item that matches the rule.\n\nIf you found this helpful please consider leaving an upvote.\n```\nclass Solution {\npublic:\n    int countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {\n        int sol = 0;\n        int temp = 0;\n        if(ruleKey == "color") temp = 1;\n        if(ruleKey == "name") temp = 2;\n        for(int i = 0; i < items.size(); i++)\n        {\n            if(items[i][temp] == ruleValue) sol++;\n        }\n        return sol;\n    }\n};\n```
['C', 'C++']