//구글콘솔 광고 추가가
신고 결과 받기

 

내 코드
using System;
using System.Collections.Generic;
public class Solution {
    public int[] solution(string[] id_list, string[] report, int k) {
        int[] answer = new int[id_list.Length];
        Dictionary<string, List<string>> resultDic = new Dictionary<string, List<string>>();
        
        foreach (string r in report)
        {
            string[] str = r.Split(" ");
            if(!resultDic.ContainsKey(str[1]))
            {
                List<string> list = new List<string>();
                list.Add(str[0]);
                resultDic.Add(str[1],list);
                continue;
            }
            if (!resultDic[str[1]].Contains(str[0]))
            {
                resultDic[str[1]].Add(str[0]);
            }
        }
        for (int i = 0; i < id_list.Length; i++)
        {
            foreach (KeyValuePair<string, List<string>> item in resultDic)
            {
                if (item.Value.Contains(id_list[i]))
                {
                    if (item.Value.Count >= k)
                    {
                        answer[i] ++;
                    }
                }
            }
        }
        return answer;
    }
}
728x90
반응형

+ Recent posts