leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1497.cpp (423B)
0 class Solution {
1 public:
2 bool canArrange(const vector<int> &arr, int k) const {
3 static int count[100000];
5 memset(count, 0x00, sizeof(count));
6 for (const int n : arr)
7 count[((n % k) + k) % k]++;
9 if (count[0] % 2 == 1) return false;
10 for (int i = 1; i <= k / 2; i++) {
11 if (count[i] != count[k - i]) return false;
12 }
14 return true;
15 }
16 };