문제: app.codility.com/programmers/lessons/4-counting_elements/frog_river_one/
Hashtable all = new Hashtable(); // O(N)
//List<int> all = new List<int>(); O(N**2)
for (int i = 0; i < A.Length; i++)
{
if (A[i] <= X && !all.Contains(A[i]))
all.Add(A[i], A[i]);
if (all.Count == X)
return i;
}
return -1;
'공부하자 > Codility' 카테고리의 다른 글
[Codility] Lesson4. MissingInteger (C#) (0) | 2020.11.17 |
---|---|
[Codility] Lesson4. MaxCounters (C#) (0) | 2020.11.17 |
[Codility] Lesson3. TapeEquilibrium (C#) (0) | 2020.11.17 |
[Codility] Lesson3. PermMissingElem (C#) (0) | 2020.11.17 |
[Codility] Lesson3. FrogJmp (C#) (0) | 2020.11.17 |