The problem. Given an array of integers nums and an integer k, return the number of (non-empty) subarrays whose sum is divisible by k — a sum of 0, k, −k, 2k … all count.
nums = [4, 5, 0, -2, -3, 1], k = 5 -> 7
nums = [5], k = 9 -> 0
nums = [-1, 2, 9], k = 2 -> 2 ([2] and [-1, 2, 9])Free account
Sign up to read the rest of this lesson: 7 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come