기존
public void main() {
String[] id_list = {"muzi", "frodo", "apeach", "neo"};
String[] report = {"muzi frodo", "apeach frodo", "frodo neo", "muzi neo", "apeach muzi"};
// String[] id_list = {"con", "ryan"};
// String[] report = {"ryan con", "ryan con", "ryan con", "ryan con"};
solution(id_list, report, 2);
}
public int[] solution(String[] id_list, String[] report, int k) {
// [신고당한사람, 신고한사람List]
HashMap<String, Set<String>> reportList = new HashMap<>();
// 첫번째 select
IntStream.range(0, report.length)
.forEach(i -> System.out.print(", report1[" + i + "] = " + report[i]));
System.out.println();
//
//삭제
int i = 0;
//
for (String reportInfo : report) {
// [고발한사람, 당한 사람]
String[] infoDeatail = reportInfo.split(" ");
// 두번째 select
System.out.println("reportInfo[" + i++ + "] = { " + infoDeatail[0] + " , " + infoDeatail[1] + " }");
//
Set<String> curReportInfo = reportList.getOrDefault(infoDeatail[1], new HashSet<>());
curReportInfo.add(infoDeatail[0]);
reportList.put(infoDeatail[1], curReportInfo);
}
HashMap<String, Integer> reportAlarmList = new LinkedHashMap<>();
Arrays.stream(id_list)
.forEach(id -> reportAlarmList.put(id, 0));
System.out.println("reportAlarmList.entrySet() = " + reportAlarmList.entrySet());
System.out.println("reportList.entrySet() = " + reportList.entrySet());
for (Map.Entry<String, Set<String>> reportInfo: reportList.entrySet()) {
System.out.print("{ reportInfo.getKey() = " + reportInfo.getKey());
System.out.println(" ,reportInfo.getValue() = " + reportInfo.getValue() + "}");
if (reportInfo.getValue().size() >= k) {
for (String name : reportInfo.getValue()) {
reportAlarmList.put(name, reportAlarmList.get(name) + 1);
}
}
}
System.out.println("reportAlarmList.entrySet() = " + reportAlarmList.entrySet());
int[] dd = reportAlarmList.entrySet().stream()
.mapToInt(x -> x.getValue())
.toArray();
return new int[2];
}
'프레임워크 > Spring boot' 카테고리의 다른 글
JWT란 ? (0) | 2022.05.02 |
---|---|
Restful api 규칙 (0) | 2022.02.10 |
MediaType.APPLICATION_JSON_UTF8가 deprecated (0) | 2022.02.05 |
Spring boot @RunWith가 어디에 ? (0) | 2022.02.05 |
restApi란 ? (0) | 2022.02.05 |