You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firstly, we need to print the modified array not just print the number of changes required.
2
+
3
+
So, we will keep track of the positions of each index of modulus.
4
+
5
+
That is we will know the indices of all the A[i]%m = x,
6
+
7
+
---------------------
8
+
9
+
Now, we will make a pass from i = 0 to m - 1
10
+
11
+
If any modulus occurs more than N/m times, then we will remove the excess indices and put them in 'extra'
12
+
13
+
If any modulus occurs less than N/m times, we will remove from extra from the end [Since the ones in the end will be closer to the current modulus.] and put it here.
14
+
15
+
We need to do two passes, not one. (This is an unusual feature of this problem.)
16
+
17
+
Because The first element might be deficient and the last may be in excess.
0 commit comments