Java Easy Solution
Complexity

Time complexity:
O(n) where n is the number of items


Space complexity:
O(1)

Code

# Complexity
- Time complexity:
O(n) where n is the number of items

- Space complexity:
O(1)

# Code
```java []
class Solution {
    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {
        int targetIndex = 0;
        int result = 0;

        switch (ruleKey) {
            case "type":
            targetIndex = 0;
            break;
            case "color":
            targetIndex = 1;
            break;
            case "name":
            targetIndex = 2;
            break;
        }
        for(List<String> item: items) {
            result += item.get(targetIndex).equals(ruleValue) ? 1 : 0;
        }
        return result;
    }
}
```
['String', 'String Matching', 'Java']