30:00
You are given an array items where items[i] = [type_i, color_i, name_i] describes the i-th item, plus a rule given by two strings ruleKey and ruleValue. An item matches the rule when the field named by ruleKey ("type", "color" or "name") equals ruleValue. Return how many items match.
1≤items.length≤1041 \leq \text{items.length} \leq 10^41≤items.length≤104
1≤typei.length,colori.length,namei.length,ruleValue.length≤101 \leq \text{type}_i.\text{length}, \text{color}_i.\text{length}, \text{name}_i.\text{length}, \text{ruleValue.length} \leq 101≤typei.length,colori.length,namei.length,ruleValue.length≤10
ruleKey\text{ruleKey}ruleKey is "type", "color" or "name".
All strings consist only of lowercase letters.
Run code to see results.
The rule is color == "silver". Only one field of each item matters.
rule
count
0
items
type
color
name
·
1
2
Each item is a triple [type, color, name]. Given a rule such as color == "silver", count how many items satisfy it.