1773. Count Items Matching a Rule

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1773

class Solution:
    def countMatches(self, items: List[List[str]], ruleKey: str, ruleValue: str) -> int:
        i = 0 if ruleKey[0] == 't' else (1 if ruleKey[0] == 'c' else 2)
        return sum(v[i] == ruleValue for v in items)