🚀🔥Straight Forward Approach🔥🚀
Approach\n1. Initialize Result Counter:\n   - Start by initializing a counter res to 0. This counter will keep track of the number of items that match the given
# Approach\n1. **Initialize Result Counter:**\n   - Start by initializing a counter `res` to 0. This counter will keep track of the number of items that match the given rule.\n\n2. **Iterate Through the Items:**\n   - Loop through each item in the `items` list using a `for` loop, with `i` ranging from 0 to the size of the list minus one.\n\n3. **Check for "type" Rule:**\n   - Inside the loop, check if `ruleKey` is equal to "type".\n   - If true, compare the first element of the current item (`items.get(i).get(0)`) with `ruleValue`.\n   - If they are equal, increment the counter `res`.\n\n4. **Check for "color" Rule:**\n   - Still inside the loop, check if `ruleKey` is equal to "color".\n   - If true, compare the second element of the current item (`items.get(i).get(1)`) with `ruleValue`.\n   - If they are equal, increment the counter `res`.\n\n5. **Check for "name" Rule:**\n   - Again inside the loop, check if `ruleKey` is equal to "name".\n   - If true, compare the third element of the current item (`items.get(i).get(2)`) with `ruleValue`.\n   - If they are equal, increment the counter `res`.\n\n6. **Return the Result:**\n   - After the loop completes, return the value of `res`, which now contains the count of items that match the specified rule.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        int res=0;\n        for(int i=0; i<items.size(); i++){\n            if(ruleKey.equals("type") && items.get(i).get(0).equals(ruleValue)) res++;\n            if(ruleKey.equals("color") && items.get(i).get(1).equals(ruleValue)) res++;\n            if(ruleKey.equals("name") && items.get(i).get(2).equals(ruleValue)) res++;\n        }\n        return res;\n    }\n}\n```\n\n![193730892e8675ebafc11519f6174bee5c4a5ab0.jpeg](https://assets.leetcode.com/users/images/44380964-be60-4e22-b42b-723a0fa6ed6b_1718960996.977102.jpeg)\n
['Java']