3512. Minimum Operations to Make Array Sum Divisible by K
Easy
10 Points
Array
Math
You are given an integer array nums and an integer k. You can perform the following operation any number of times:
Return the minimum number of operations required to make the sum of the array divisible by k.
Examples
Example 1
Input: nums = [3,9,7], k = 5
Output: 4
Explanation:
Example 2
Input: nums = [4,1,3], k = 4
Output: 0
Explanation:
Example 3
Input: nums = [3,2], k = 6
Output: 5
Explanation:
Constraints
1 <= nums.length <= 1000
1 <= nums[i] <= 1000
1 <= k <= 100
3512. Minimum Operations to Make Array Sum Divisible by K
Easy
10 Points
Array
Math
You are given an integer array nums and an integer k. You can perform the following operation any number of times:
Return the minimum number of operations required to make the sum of the array divisible by k.
Examples
Example 1
Input: nums = [3,9,7], k = 5
Output: 4
Explanation:
Example 2
Input: nums = [4,1,3], k = 4
Output: 0
Explanation:
Example 3
Input: nums = [3,2], k = 6
Output: 5
Explanation:
Constraints
1 <= nums.length <= 1000
1 <= nums[i] <= 1000
1 <= k <= 100
Minimum Operations to Make Array Sum Divisible by K - Practice Coding | SlaveCode