💯🔥O(1) space complexity 🔥💯|| 💯🔥100% beat in Java🔥💯 || 💯🔥easy to understand 🔥💯
Approach\ncheck String is equal or not\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\n    public int coun
# Approach\ncheck String is equal or not\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 index=0;\n        if(ruleKey.equals("color"))index =1;\n        else if(ruleKey.equals("name"))index=2;\n\n        int ans=0;\n        for(int i=0 ; i<items.size() ; i++){\n            if(items.get(i).get(index).equals(ruleValue))ans++;  \n        }\n        return ans;\n    }\n}\n```
['Java']