Match fixing solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n\n# Code\n\nclass Solution {\n    public int countMatches(List<List<String>> items,
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/3afc1634-9bf6-4067-ad26-d7bbca6fc1fd_1691915490.7061198.png)\n\n\n# Code\n```\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        int count = 0;  // Initialize a counter to keep track of matching items.\n\n        String type = "type";  // Define the string constants for different ruleKeys.\n        int i = 0;  // Initialize the index variable to access the correct property of the items.\n\n        // Check the value of ruleKey and set the index (i) accordingly.\n        if (ruleKey.equals(type)) {\n            i = 0;  // If ruleKey is "type", set index to 0 (type property).\n        }\n        String color = "color";\n        if (ruleKey.equals(color)) {\n            i = 1;  // If ruleKey is "color", set index to 1 (color property).\n        }\n        String name = "name";\n        if (ruleKey.equals(name)) {\n            i = 2;  // If ruleKey is "name", set index to 2 (name property).\n        }\n\n        // Iterate through each item in the items list.\n        for (int j = 0; j < items.size(); j++) {\n            // Check if the property at index i of the current item matches ruleValue.\n            if (items.get(j).get(i).equals(ruleValue)) {\n                count++;  // If there\'s a match, increment the count.\n            }\n        }\n        \n        return count;  // Return the final count of items that match the rule.\n    }\n}\n\n```
['Java']