[Java] 100% time 100% space readable easy solution (Find type then count)
If you like Please Upvote this Java Solution\n\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n   
If you like Please __Upvote__ this Java Solution\n```\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        \n        //Detecting which rule is applicable and storing it\'s index\n        \n        int ruleIndex;\n        if(ruleKey.equals("type"))\n            ruleIndex = 0;\n        else if(ruleKey.equals("color"))\n            ruleIndex = 1;\n        else\n            ruleIndex = 2;\n        \n        //iterating over the items list and counting number of items having\n        //the given ruleValue at the ruleIndex position\n        \n        int count = 0;\n        int n = items.size();\n        for(int item = 0 ; item < n; item++){\n            if(items.get(item).get(ruleIndex).equals(ruleValue))\n                count++;\n        }\n        \n        return count;\n    }\n}\n```
['Java']