12월 18일 풀이

임덤덤·2023년 12월 18일
0

하드코딩으로 Output은 맞춰둔 상태 , 내일 시간복잡도 줄이는 과정 진행예정

function solution(id_list, report, k) {
  const sortReport = [];
  const reportCount = {};
  const 정지 = [];
  const 통지 = {};
  const result = [];

  id_list.forEach((el) => {
    reportCount[el] = 0;
  });

  id_list.forEach((el) => {
    통지[el] = 0;
  });

  report.forEach((el) => {
    sortReport.push(el.split(" "));
  });

  sortReport.forEach((el) => {
    const reportCountKey = Object.keys(reportCount);
    reportCountKey.forEach((key) => {
      if (el[1] === key) {
        reportCount[el[1]] += 1;
      }
    });
  });

  for (const test in reportCount) {
    if (reportCount[test] === k) {
      정지.push(test);
    }
  }

  sortReport.forEach((el) => {
    정지.map((user) => {
      if (el[1] === user) {
        통지[el[0]] += 1;
      }
    });
  });

  for (const i in 통지) {
    result.push(통지[i]);
  }

  return result;
}
profile
응애🐣 예비 개발자 입니다.

0개의 댓글