문제: app.codility.com/programmers/lessons/4-counting_elements/max_counters/
MaxCounters coding task - Learn to Code - Codility
Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum.
app.codility.com
77% (다시 풀어야 함)
            int[] result = new int[N];
            int max = 0;
            for (int i = 0; i < A.Length; i++)
            {
                int position = A[i] - 1;
                if (A[i] >= 1 && A[i] <= N)
                {
                    result[position] = result[position] + 1;
                    if (max < result[position])
                        max = result[position];
                }
                else if (A[i] > N)
                {
                    for (int j = 0; j < result.Length; j++)
                        result[j] = max;
                }
            }
            return result;'공부하자 > Codility' 카테고리의 다른 글
| [Codility] Lesson4. PermCheck (C#) (0) | 2020.11.17 | 
|---|---|
| [Codility] Lesson4. MissingInteger (C#) (0) | 2020.11.17 | 
| [Codility] Lesson4. FrogRiverOne (C#) (0) | 2020.11.17 | 
| [Codility] Lesson3. TapeEquilibrium (C#) (0) | 2020.11.17 | 
| [Codility] Lesson3. PermMissingElem (C#) (0) | 2020.11.17 |