All Posts
Leetcode 1773: Count Items Matching a Rule
You are given an array items, where each items[i] represents the type, color, and name of the ith item. You are also given a rule consisting of two strings: ruleKey and ruleValue. The task is to count how many items match the rule. An item matches the rule if one of the following conditions is true:
ruleKey == 'type'andruleValuematches the type of the item.ruleKey == 'color'andruleValuematches the color of the item.ruleKey == 'name'andruleValuematches the name of the item.