Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c4ffcc5

Browse files
Update 신고-결과-받기.js
1 parent 5485504 commit c4ffcc5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎level-1/신고-결과-받기.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,31 @@ function solution(id_list, report, k) {
124124

125125
return answer;
126126
}
127+
128+
//정답 5 - chaerin-dev
129+
function solution(id_list, report, k) {
130+
// 한 유저가 같은 유저를 여러 번 신고한 경우는 신고 횟수 1회로 처리
131+
let set = new Set(report);
132+
report = Array.from(set);
133+
134+
// 1. report를 2차원배열로 변형
135+
// 2. 각 유저가 신고당한 횟수 cnt에 저장
136+
// 3. 각 유저를 신고한 유저 who에 저장
137+
let cnt = Array.from({ length: id_list.length }, (i) => 0);
138+
let who = Array.from({ length: id_list.length }, (i) => []);
139+
for (let i = 0; i < report.length; i++) {
140+
report[i] = report[i].split(" ");
141+
cnt[id_list.indexOf(report[i][1])]++;
142+
who[id_list.indexOf(report[i][1])].push(report[i][0]);
143+
}
144+
145+
// k회 이상 신고당한 유저 확인 및 각 유저가 받은 메일 개수 mail에 저장
146+
let mail = Array.from({ length: id_list.length }, (i) => 0);
147+
for (let i = 0; i < cnt.length; i++) {
148+
if (cnt[i] < k) continue;
149+
for (let j = 0; j < who[i].length; j++) {
150+
mail[id_list.indexOf(who[i][j])]++;
151+
}
152+
}
153+
return mail;
154+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /