문제: app.codility.com/programmers/lessons/6-sorting/distinct/
if (A.Length == 0)
return 0;
List<int> ListA = new List<int>(A);
ListA.Sort();
int result = 1;
int index = ListA[0];
for (int i = 0; i < ListA.Count; i++)
{
if (ListA[i] != index)
{
result = result + 1;
index = ListA[i];
}
}
return result;
'공부하자 > Codility' 카테고리의 다른 글
[Codility] Lesson6. NumberOfDiscIntersections (C#) (0) | 2020.11.20 |
---|---|
[Codility] Lesson6. MaxProductOfThree (C#) (0) | 2020.11.20 |
[Codility] Lesson5. PassingCars (C#) (0) | 2020.11.17 |
[Codility] Lesson5. MinAvgTwoSlice (C#) (0) | 2020.11.17 |
[Codility] Lesson5. GenomicRangeQuery (C#) (0) | 2020.11.17 |