BEGINNERS solution || C++ || Easy understanding
It\'s a very easy understandable solution\nT.C. = O(N)\nS.C.=O(1)\n# APPROACH (Intution):-\nSince in a 2-d vector , in every row there is only 3 columns and 1st
**It\'s a very easy understandable solution\nT.C. = O(N)\nS.C.=O(1)**\n# APPROACH (Intution):-\n**Since in a 2-d vector , in every row there is only 3 columns and 1st column is for type , 2nd is for color, 3rd is for name\ntherefore it is clear that for specific ruleKey we have to just traverse a row for particular column using single loop  \n**\n*steps mention below:---*\n**step 1-- check if ruleKey is type , if it is then , traverse each row in 0th (i.e. first column) for count and\n                       if items[i][0] matches with keyValue given , then increase count.\n\t\t\t\t\t   \nstep2-- check if ruleKey is color , if it is then , traverse each row in 1st (i.e. second column) for count and\n                       if items[i][1] matches with keyValue given , then increase count. \n\t\t\t\t\t   \nstep3-- check if ruleKey is name , if it is then , traverse each row in 2nd (i.e. third column) for count and\n                       if items[i][2] matches with keyValue given , then increase count. \t\t\t\t\t   **\n\t\t\t\t  \nstep-- return count.\n\n```\nclass Solution {\npublic:\n    int countMatches(vector<vector<string>>& items, string ruleKey, string ruleValue) {\n        int count=0;\n        \n       if(ruleKey=="type"){\n           for(int i=0;i<items.size();i++){\n               if(items[i][0]==ruleValue){\n                   count++;\n               }\n           }\n       }\n         else if(ruleKey=="color"){\n           for(int i=0;i<items.size();i++){\n               if(items[i][1]==ruleValue){\n                   count++;\n               }\n           }\n       }\n         else if(ruleKey=="name"){\n           for(int i=0;i<items.size();i++){\n               if(items[i][2]==ruleValue){\n                   count++;\n               }\n           }\n       }\n        return count;\n        \n    }\n};\n```\n\n\n\n\n\n
['Array', 'C', 'C++']