Tap here to switch tabs
Problem
Submissions

Problem: Subarray Sums Divisible by K

Subarray Sums Divisible by K gives an integer array, possibly with negative values, and a divisor. Return the number of nonempty contiguous subarrays whose sum is a multiple of the divisor.

Statement

Given an integer array nums and an integer k, return the number of non empty contiguous subarrays of nums whose sum is divisible by k.

Constraints:

  • 1≤1 \leq nums.length ≤3∗104\leq 3 * 10^4

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

  • 2≤2 \leq k ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Subarray Sums Divisible by K

Subarray Sums Divisible by K gives an integer array, possibly with negative values, and a divisor. Return the number of nonempty contiguous subarrays whose sum is a multiple of the divisor.

Statement

Given an integer array nums and an integer k, return the number of non empty contiguous subarrays of nums whose sum is divisible by k.

Constraints:

  • 1≤1 \leq nums.length ≤3∗104\leq 3 * 10^4

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

  • 2≤2 \leq k ≤104\leq 10^4