Skip to content

Practice Count Array Pairs 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.

Hard#2183
LeetCode Problem

Count Array Pairs Divisible by K

Problem Statement

Count index pairs i < j in nums for which nums[i] * nums[j] is divisible by k. Equal values at different indices remain separate pair choices. Return the count.

Source: Count Array Pairs Divisible by K on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3,4,5], k = 2
Output
7

# Example 2

Input
nums = [1,2,3,4], k = 5
Output
0

Constraints

1 <= nums.length <= 10^5
1 <= nums[i], k <= 10^5

Related LeetCode Problems

Practice more problems similar to Count Array Pairs Divisible by K.

Review your practice with PhantomCodeAI

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