We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main.java.com.poogle.PG.Q92334; import java.util.*; public class Solution { public static void main(String[] args) { System.out.println(Arrays.toString(solution(new String[]{"muzi", "frodo", "apeach", "neo"}, new String[]{"muzi frodo", "apeach frodo", "frodo neo", "muzi neo", "apeach muzi"}, 2))); System.out.println(Arrays.toString(solution(new String[]{"con", "ryan"}, new String[]{"ryan con", "ryan con", "ryan con", "ryan con"}, 3))); } private static int[] solution(String[] id_list, String[] report, int k) { Set<String> reportSet = new HashSet<>(Arrays.asList(report)); Map<String, Integer> reportMap = new HashMap<>(); Map<String, Set<String>> reportList = new HashMap<>(); Map<String, Integer> result = new HashMap<>(); for (String id : id_list) { reportMap.put(id, 0); reportList.put(id, new HashSet<>()); result.put(id, 0); } for (String rp : reportSet) { String[] list = rp.split(" "); reportList.get(list[0]).add(list[1]); reportMap.put(list[1], reportMap.get(list[1]) + 1); } List<String> reportedList = new ArrayList<>(); for (Map.Entry<String, Integer> entry : reportMap.entrySet()) { if (entry.getValue() >= k) { reportedList.add(entry.getKey()); } } for (Map.Entry<String, Set<String>> entry : reportList.entrySet()) { Set<String> findList = entry.getValue(); for (String s : reportedList) { if (findList.contains(s)) { result.put(entry.getKey(), result.get(entry.getKey()) + 1); } } } int[] answer = new int[id_list.length]; for (int i = 0; i < id_list.length; i++) { answer[i] = result.get(id_list[i]); } return answer; } }
The text was updated successfully, but these errors were encountered:
b6cb145
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: