로딩
요청 처리 중입니다...

JAVA_LeetCode 1773_Count Items Matching a Rule

 JAVA_LeetCode 1773_Count Items Matching a Rule

JAVA_LeetCode 1773_Count Items Matching a Rule 풀이 class Solution { public int countMatches(List items, String ruleKey, String ruleValue) { // 항목 값을 구한다. int idx = 0, res = 0; if(ruleKey.equals("color")) idx = 1; else if(ruleKey.equals("name")) idx = 2; // 항목값의 value가 일치하는 경우 출력값을 더해준다. for(int i = 0 ; i < items.size() ; i++){ if(items.get(i).get(idx).equals(ruleValue)) res++; } return res; } } * 출처 https://leetcode.com/problems/count-items-matching-a-rule...

# JAVA # JAVA_CountItemsMatchingaRule # JAVA_LeetCode1773 # JAVA_LeetCode1773_CountItemsMatchingaRule # LeetCode1773_CountItemsMatchingaRule