Skip to content

🟡 Port problem 1497 (Check If Array Pairs Are Divisible by k) from Python to C++23 - #10

Open
AF2B wants to merge 2 commits into
chore/cpp23-migrationfrom
feat/cpp-1497-check-if-array-pairs-are-divisible-by-k
Open

AF2B wants to merge 2 commits into
chore/cpp23-migrationfrom
feat/cpp-1497-check-if-array-pairs-are-divisible-by-k

Conversation

@AF2B

@AF2B AF2B commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Converts python/1497.py to C++23 at solutions/1401-1500/1497-check-if-array-pairs-are-divisible-by-k/.
  • The original only checked mirrored pairs (arr[i] with arr[n-1-i]) — a stricter condition than the real problem (any valid pairing). It passed its own tests but wasn't the general algorithm. Replaced with the standard remainder-counting approach.
  • Removes the now-converted python/1497.py.

Base is chore/cpp23-migration (#4) — retarget to main once that lands.

Test plan

  • CI (build & test, static analysis, format check) passes.

…thon to C++23

Replaces python/1497.py with
solutions/1401-1500/1497-check-if-array-pairs-are-divisible-by-k/.

The original Python only checked mirrored pairs (arr[i] with
arr[n-1-i]), which is a stricter condition than the actual problem
(any valid pairing) — it happened to pass its own tests but isn't the
real algorithm. Replaced with the standard remainder-counting
approach: count arr[i] % k for each element, then require freq[0] to
be even and freq[r] == freq[k - r] for every other remainder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants