2025-08-15 11:37:22 +0000 UTC
Count Items Matching a Rule
Categories:
Links
Code
class Solution:
def countMatches(self, items: List[List[str]], ruleKey: str, ruleValue: str) -> int:
count = 0
for type, color, name in items:
if (
(ruleKey == "type" and ruleValue == type)
or (ruleKey == "color" and ruleValue == color)
or (ruleKey == "name" and ruleValue == name)
):
count += 1
return count