Skip to content

Commit a9ca567

Browse files
authored
Added Count Items Matching a Rule.java
1 parent 53703d4 commit a9ca567

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Easy/Count Items Matching a Rule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {
3+
int ruleIdx = ruleKey.equals("type") ? 0 : (ruleKey.equals("color") ? 1 : 2);
4+
return (int) items.stream().filter(item -> item.get(ruleIdx).equals(ruleValue)).count();
5+
}
6+
}

0 commit comments

Comments
 (0)