package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/count-items-matching-a-rule/
 */
public class Problem1773 {
    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1773 prob = new Problem1773();
        System.out.println(prob.countMatches(List.of(
            List.of("phone","blue","pixel"),
            List.of("computer","silver","lenovo"),
            List.of("phone","gold","iphone")),
            "color", "silver")); // 1
        System.out.println(prob.countMatches(List.of(
            List.of("phone","blue","pixel"),
            List.of("computer","silver","lenovo"),
            List.of("phone","gold","iphone")),
            "color", "phone")); // 2
    }
}

@@ -29,20 +29,68 @@
 va.util.
-List
+HashMap;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0A%0A/**%0A 
@@ -283,328 +283,300 @@
     
-// TODO%0A        return 0
+Map%3CString, Integer%3E typeCount = new HashMap%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1773 prob = new Problem1773();%0A        System.out.println(prob.countMatches(List.of(%0A            List.of(%22phone%22,%22blue%22,%22pixel%22),%0A            List.of(%22computer%22,%22silver%22,%22lenovo%22),%0A            List.of(%22phone%22,%22gold%22,%22iphone%22)),
+Map%3CString, Integer%3E colorCount = new HashMap%3C%3E();%0A        Map%3CString, Integer%3E nameCount = new HashMap%3C%3E();%0A        for (List%3CString%3E item : items) %7B%0A            typeCount.put(item.get(0), typeCount.getOrDefault(item.get(0), 0) + 1);
 %0A   
@@ -588,230 +588,316 @@
     
-%22
 color
-%22, %22silver%22)); // 1%0A        System.
+Count.put(item.get(1), colorCount.getOrDefault(item.get(1), 0) + 1);%0A            nameC
 ou
+n
 t.p
-rintln(prob.countMatches(List.of(
+ut(item.get(2), nameCount.getOrDefault(item.get(2), 0) + 1);
 %0A     
+   %7D%0A
        
-List.of(%22phone%22,%22blue%22,%22pixel%22),%0A            List.of(%22computer%22,%22silver%22,%22lenovo%22),%0A            List.of(%22phone%22,%22gold%22,%22iphone%22)),
+ if (ruleKey.equals(%22type%22)) %7B%0A            return typeCount.getOrDefault(ruleValue, 0);%0A        %7D else if (ruleKey.equals(%22color%22)) %7B
 %0A   
@@ -909,32 +909,116 @@
     
-%22color%22, %22phone%22)); // 2
+return colorCount.getOrDefault(ruleValue, 0);%0A        %7D%0A        return nameCount.getOrDefault(ruleValue, 0);
 %0A   

Solve problem 1773