#3512

Minimum Operations to Make Array Sum Divisible by K

easy · 92.4% accepted · 324 likes · top 100%

array · math

Description

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.

Solution