Count Items Matching a Rule LeetCode solution in Python

1
class Solution:
2
def countMatches(self, items: List[List[str]], ruleKey: str, ruleValue: str) -> int:
3
d = {"type": 0, "color": 1, "name": 2}
4
return sum(1 for item in items if item[d[ruleKey]] == ruleValue)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0