class Solution {
public int[] missingRolls(int[] rolls, int mean, int n) {
int m = rolls.length;
int total = 0;
for (int roll : rolls) {
total += roll;
}
int leftSum = mean*(m+n) - total;
int leftMean = leftSum/n;
if (leftMean <= 0 || leftMean > 6) {
return new int[]{};
}
int remainder = leftSum%n;
if (leftMean == 6 && remainder != 0) {
return new int[]{};
}
int[] res = new int[n];
Arrays.fill(res, leftMean);
for (int i = 0; i < remainder; i++) {
res[i]++;
}
return res;
}
}