Tap here to switch tabs
Problem
Submissions

Problem: Check If Array Pairs Are Divisible by k

med
30 min
Try to solve the Check If Array Pairs Are Divisible by k problem.

Statement

Given an integer array arr of length n and an integer k, determine whether it is possible to partition arr into exactly n2\frac{n}{2} disjoint pairs such that, for every pair, the sum of the two elements is divisible by k. Return true if such a pairing exists, otherwise return false.

Constraints:

  • arr.length == n

  • 1≤‘n‘≤1051 \leq `n` \leq 10^5

  • n is even

  • −109≤‘arr[i]‘≤109-10^9 \leq `arr[i]` \leq 10^9

  • 1≤‘k‘≤1051 \leq `k` \leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check If Array Pairs Are Divisible by k

med
30 min
Try to solve the Check If Array Pairs Are Divisible by k problem.

Statement

Given an integer array arr of length n and an integer k, determine whether it is possible to partition arr into exactly n2\frac{n}{2} disjoint pairs such that, for every pair, the sum of the two elements is divisible by k. Return true if such a pairing exists, otherwise return false.

Constraints:

  • arr.length == n

  • 1≤‘n‘≤1051 \leq `n` \leq 10^5

  • n is even

  • −109≤‘arr[i]‘≤109-10^9 \leq `arr[i]` \leq 10^9

  • 1≤‘k‘≤1051 \leq `k` \leq 10^5