diff --git a/src/main/java/com/fishercoder/solutions/_1773.java b/src/main/java/com/fishercoder/solutions/_1773.java index 306b2642aa..9f1bb563b0 100644 --- a/src/main/java/com/fishercoder/solutions/_1773.java +++ b/src/main/java/com/fishercoder/solutions/_1773.java @@ -5,13 +5,19 @@ public class _1773 { public static class Solution1 { public int countMatches(List> items, String ruleKey, String ruleValue) { + int index =0; + if(ruleKey.equals("color")){ + index =1; + } + if(ruleKey.equals("name")){ + index =2; + } + int match = 0; + + for (List item : items) { - if (ruleKey.equals("type") && item.get(0).equals(ruleValue)) { - match++; - } else if (ruleKey.equals("color") && item.get(1).equals(ruleValue)) { - match++; - } else if (ruleKey.equals("name") && item.get(2).equals(ruleValue)) { + if(item.get(index).equals(ruleValue)){ match++; } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy