Easy approach |C++ |O(n) |86%+ |Beginner friendly
Intuition\nGet the key and compare for value\n\n# Approach\nCalculate the column to check\nKeep checking the column for the value required\n\n# Complexity\n- Ti
# Intuition\nGet the key and compare for value\n\n# Approach\nCalculate the column to check\nKeep checking the column for the value required\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {\n        int res = 0;\n        int key = 2;\n        if(ruleKey == "type")                            key = 0;\n        else if(ruleKey == "color")                      key = 1;\n        for(int i = 0; i < items.size(); i++)            if(items[i][key] == ruleValue) res++;\n        return res;\n    }\n};\n```
['Array', 'String', 'C++']