leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE |

commit3625b6037f16d2c955c6a3aa8016c9702ca3d109
parent588fb8fa1a06bda90c374f5077b00fa56159d67c
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateTue, 1 Oct 2024 07:15:29 +0200

Daily problem

Diffstat:
AProblems/1497.cpp|+++++++++++++++++
MREADME.md|+

2 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/Problems/1497.cpp b/Problems/1497.cpp

@@ -0,0 +1,17 @@

class Solution {
public:
bool canArrange(const vector<int> &arr, int k) const {
static int count[100000];
memset(count, 0x00, sizeof(count));
for (const int n : arr)
count[((n % k) + k) % k]++;
if (count[0] % 2 == 1) return false;
for (int i = 1; i <= k / 2; i++) {
if (count[i] != count[k - i]) return false;
}
return true;
}
};

diff --git a/README.md b/README.md

@@ -874,6 +874,7 @@ for solving problems.

| 1492 | Medium | [The kth Factor of n](Problems/1492.cpp) |
| 1493 | Medium | [Longest Subarray of 1's After Deleting One Element](Problems/1493.cpp) |
| 1496 | Easy | [Path Crossing](Problems/1496.cpp) |
| 1497 | Medium | [Check If Array Pairs Are Divisible by k](Problems/1497.cpp) |
| 1498 | Medium | [Number of Subsequences That Satisfy the Given Sum Condition](Problems/1498.cpp) |
| 1502 | Easy | [Can Make Arithmetic Progression From Sequence](Problems/1502.cpp) |
| 1503 | Medium | [Last Moment Before All Ants Fall Out of a Plank](Problems/1503.cpp) |