3512. Minimum Operations to Make Array Sum Divisible by K
You are given an integer array nums and an integer k. You can perform the following operation any number of times: - Select an index i and replace nums[i] with nums[i] - 1. Return the minimum number of operations required to make the sum of the array divisible by k. Example 1: Input: nums = [3,9,7], k = 5 Output: 4 Explanation: - Perform 4 operations on nums[1] = 9. Now, nums = [3, 5, 7].
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start