✅Easiest Basic C++ Solutions | No Advance Logic| 100% efficient✅
Logic:\nHere\'s a breakdown of what the solution does:\n\n1. It initializes a variable count to keep track of the number of matches found.\n1. It determines the
**Logic:**\nHere\'s a breakdown of what the solution does:\n\n1. It initializes a variable count to keep track of the number of matches found.\n1. It determines the index of the ruleKey (either 0 for "type", 1 for "color", or 2 for "name").\n1. It iterates through each item in the items vector.\n1. For each item, it compares the value at the determined index (based on the ruleKey) with the ruleValue.\n1. If the comparison is true (i.e., if the item matches the rule), it increments the count.\n1. After iterating through all items, it returns the final value of count, which represents the number of items that match the given rule.\n1. \n\n\n\n**Code:**\n```\nclass Solution {\npublic:\n    int countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {//2d vector \n        \n        int count=0;\n        int keyIndex=0;\n        if(ruleKey == "color")\n        {                          //  0      1       2\n            keyIndex=1; //set index  [typei, colori, namei]  this is a row\n        } \n        else if(ruleKey == "name")\n        {\n            keyIndex=2;\n        }\n              \n        for(size_t i=0;i<items.size();i++)\n        {\n            if(items[i][keyIndex]==ruleValue)\n                count++;\n        }\n         return count;                                                                             \n    }\n    \n};
['Array', 'C']