Problem: Count Items Matching a Rule
Explore how to implement a linear search algorithm in Go to count items matching specific criteria in an array. Learn to map rule keys to array indices for efficient comparison and understand the time and space complexity involved in this approach.
We'll cover the following...
We'll cover the following...
Statement
You are given an array items, where each items[i] = [type_i, color_i, name_i] represents the type, color, and name of the ruleKey and ruleValue, that together define a matching rule.
An item is considered a match if any of the following conditions holds:
ruleKey == "type"andruleValue == type_iruleKey == "color"andruleValue == color_iruleKey == "name"andruleValue == name_i
Return the total number of items in items that match the given rule.
Constraints:
...