강의로 돌아가기

이건 디버거 없이, 코딩하기란 매우 어렵겠네요

값으로 정렬도 해야하고, 중복되는 값도 처리해야하고 복잡하군요

작성중인 코드―Solution.cs
``````1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;

public class Solution {
public int[] solution(string[] genres, int[] plays)
{
List<int> arr = new List<int>();

var dicPlayCount = new Dictionary<string, int>();
var dicPlays = new Dictionary<string, SortedList<int, int>>();

for (int i = 0; i < genres.Length; ++i)
{
if (!dicPlayCount.ContainsKey(genres[i]))
else
dicPlayCount[genres[i]] += plays[i];

if (!dicPlays.ContainsKey(genres[i]))
}

var vOrdered = new SortedList<int, string>(new DuplicateKeyComparer<int>());
foreach (var v in dicPlayCount)
{
}

for (int k = vOrdered.Count -1; k >=0; --k)
{
var v = vOrdered.Values[k];
var vElem = dicPlays[v];

int j = 0;
for (int i = vElem.Count - 1; i >= 0 && j < 2; --i, ++j)
{
var vNumber = vElem.Values[i];
}
}

return arr.ToArray();
}

private class DuplicateKeyComparer<TKey> : IComparer<TKey> where TKey : IComparable
{
public int Compare(TKey x, TKey y)
{
int result = x.CompareTo(y);

if (result == 0)
return 1;   // Handle equality as beeing greater
else
return result;
}
}
}
``````