Skip to content

Practice Check If Array Pairs Are Divisible by k

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1497
LeetCode Problem

Check If Array Pairs Are Divisible by k

Problem Statement

Given an array of integers arr of even length n and an integer k. We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k. Return true If you can find a way to do that or false otherwise.

Source: Check If Array Pairs Are Divisible by k on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
arr = [1,2,3,4,5,10,6,7,8,9], k = 5
Output
true

# Example 2

Input
arr = [1,2,3,4,5,6], k = 7
Output
true

# Example 3

Input
arr = [1,2,3,4,5,6], k = 10
Output
false

Constraints

arr.length == n
1 <= n <= 10^5
n is even.
-10^9 <= arr[i] <= 10^9
1 <= k <= 10^5

Related LeetCode Problems

Practice more problems similar to Check If Array Pairs Are Divisible by k.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.