728x90
PermCheck c++
-
[codility] PermCheck c++Coding Test/codility 2022. 4. 9. 21:32
문제 permutation(순열) 인지 체크하는 문제이다. 문제 해결 처음에 생각한 풀이는 75%가 나왔다. 1. A배열의 합 구하기 2. A배열의 크기로 A.size() 일 때 순열의 합 구하기 3. 1,2 비교하기 #include #include #include #include #include int solution3(std::vector &A) { int len = A.size()+1; long sumP = len * (len + 1) / 2; long sumA = std::accumulate(A.begin(), A.end(), 0); if (sumP != sumA) return 0; return 1; } #define PermCheck #ifdef PermCheck int main() { std:..