[c++/python solution] simple and easy to understand with comment
c++:\n\n\n\tclass Solution {\n\tpublic:\n\t\tint countMatches(vector>& items, string ruleKey, string ruleValue) {\n\t\t\t// take a count variable for count key 
c++:\n\n\n\tclass Solution {\n\tpublic:\n\t\tint countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {\n\t\t\t// take a count variable for count key values\n\t\t\tint count = 0;\n\t\t\t// take a variable for final answer\n\t\t\tint res = 0;\n\t\t\t// Note here only 3 description type color and name so we can do one by one (brute force)\n\n\t\t\t// first we can use color as key and find all with maching color\n\t\t\tif(ruleKey=="color"){\n\t\t\t\tfor(int i = 0; i < items.size(); i++){\n\t\t\t\t\t// if color value if same as given value then increase counter\n\t\t\t\t\tif(items[i][1] == ruleValue)\n\t\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\t// update the result as maximum color matches\n\t\t\t\tres = max(res, count);\n\t\t\t}\n\t\t\t// if kye is not color then check for type\n\t\t\telse if(ruleKey == "type"){\n\t\t\t\t// reset counter as 0\n\t\t\t\tcount = 0;\n\t\t\t\tfor(int i = 0; i < items.size(); i++){\n\t\t\t\t\tif(items[i][0] == ruleValue)\n\t\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\t// update the result as maximum color matches\n\t\t\t\tres = max(res, count);\n\t\t\t}\n\t\t\t// if not color and type then check for name\n\t\t\telse if(ruleKey == "name"){\n\t\t\t\t// reinitilaze the counter\n\t\t\t\tcount = 0;\n\t\t\t\tfor(int i = 0; i < items.size(); i++){\n\t\t\t\t\tif(items[i][2] == ruleValue)\n\t\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\t// update the result as maximum color matches\n\t\t\t\tres = max(res, count);\n\t\t\t}\n\t\t\t// return maximum matches result \n\t\t\treturn res;\n\t\t}\n\t};\n\t\nC++ using map\n\n\tclass Solution {\n\tpublic:\n\t\tint countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {\n\t\t\tunordered_map<string, vector<string>> mp;\n\t\t\tfor(int i = 0; i < items.size(); i++){\n\t\t\t\tmp["type"].push_back(items[i][0]);\n\t\t\t\tmp["color"].push_back(items[i][1]);\n\t\t\t\tmp["name"].push_back(items[i][2]);\n\t\t\t}\n\t\t\tint ans = 0;\n\t\t\tfor(int i = 0; i < 3; i++){\n\t\t\t\tint xx = count(mp[ruleKey].begin(), mp[ruleKey].end(), ruleValue);\n\t\t\t\tans = ans>xx? ans:xx;\n\t\t\t}\n\t\t\treturn ans;\n\n\t\t}\n\t};\n\n\nPython:\n\n\tclass Solution:\n\t\t\tdef countMatches(self, items: List[List[str]], ruleKey: str, ruleValue: str) -> int:\n\t\t\t\tdic = {}\n\t\t\t\tdic[\'type\'] = []\n\t\t\t\tdic[\'color\'] = []\n\t\t\t\tdic[\'name\'] = []\n\t\t\t\tfor  item in items:\n\t\t\t\t\tdic[\'type\'].append(item[0])\n\t\t\t\t\tdic[\'color\'].append(item[1])\n\t\t\t\t\tdic[\'name\'].append(item[2])\n\n\t\t\t\treturn dic[ruleKey].count(ruleValue)\n
['C', 'Python']