← All questions
MediumCoding
Check If Array Pairs Are Divisible by k
Asked at
Visa
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Reject odd array length.
- 02Count normalized remainders modulo k.
- 03Match remainder r with k minus r.
- 04Handle remainder zero specially.
- 05Handle k even and r equals k/2 specially.
Reference answer
Then expect these follow-ups
How would you output the pairs as well as validate them?
Tests: follow-up reasoning
Can this be done in one pass with a map?
Tests: follow-up reasoning
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question