Skip to content
Onsite

Divisible Sum Pairs

EasyP3Coding

Return the number of pairs of indices (i, j) with i < j for which nums[i] + nums[j] is divisible by k.

Example 1

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

Example 2

Input
nums = [1,2,3], k = 1
Output
3

Example 3

Input
nums = [], k = 3
Output
0

Constraints

  • 0 <= nums.length <= 10^5
  • 1 <= k <= 100
  • 1 <= nums[i] <= 10^5

Hints

Run checks the 3 visible tests, Submit all 10.