-
[codility] MaxCounters c++Coding Test/codility 2022. 4. 10. 10:01728x90
- 문제
- 문제 풀이
#include <algorithm> #include <vector> #include <iostream> int solution(std::vector<int> &A) { sort(A.begin(), A.end()); int index = A.size() - 1; if (A.at(index) < 0) return 1; int min = 1; for (int i = 0; i < index + 1; i++) { if (min == A[i]) min++; } return min; } #define MaxCounters #ifdef MaxCounters int main() { std::vector<int> nVec = { 1,3,6,4,1,2}; std::cout << solution(nVec); return 0; } #endif
728x90'Coding Test > codility' 카테고리의 다른 글
[Codility] NumberSolitaire c++ (0) 2022.09.16 [Codility] GenomicRangeQuery c++ (0) 2022.08.11 [codility] MaxCounters c++ (0) 2022.04.10 [codility] PermCheck c++ (0) 2022.04.09 [codility] FrogRiverOne c++ (0) 2022.04.09