You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls.

You are given an integer array rolls of length m where rolls[i] is the value of the ith observation. You are also given the two integers mean and n.

Return an array of length n containing the missing observations such that the average value of the n + m rolls is exactly mean. If there are multiple valid answers, return any of them. If no such array exists, return an empty array.

The average value of a set of k numbers is the sum of the numbers divided by k.

Note that mean is an integer, so the sum of the n + m rolls should be divisible by n + m.

&nbsp;
Example 1:

Input: rolls = [3,2,4,3], mean = 4, n = 2
Output: [6,6]
Explanation: The mean of all n + m rolls is (3 + 2 + 4 + 3 + 6 + 6) / 6 = 4.


Example 2:

Input: rolls = [1,5,6], mean = 3, n = 4
Output: [2,3,2,2]
Explanation: The mean of all n + m rolls is (1 + 5 + 6 + 2 + 3 + 2 + 2) / 7 = 3.


Example 3:

Input: rolls = [1,2,3,4], mean = 6, n = 4
Output: []
Explanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are.


&nbsp;
Constraints:


	m == rolls.length
	1 &lt;= n, m &lt;= 105
	1 &lt;= rolls[i], mean &lt;= 6


class Solution:
    def missingRolls(self, rolls: List[int], mean: int, n: int) -> List[int]:
        missing_val, rem = divmod(mean * (len(rolls) + n) - sum(rolls), n)
        if rem == 0:
            if 1 <= missing_val <= 6:
                return [missing_val] * n
        elif 1 <= missing_val < 6:
            return [missing_val + 1] * rem + [missing_val] * (n - rem)
        return []
class Solution {
    public int[] missingRolls(int[] rolls, int mean, int n) {
        
    	int i,m=rolls.length,sum=0;
    	for(i=0;i<m;i++)
    		sum+=rolls[i];
			
    	int x=(mean*(m+n))-sum;
		
		if(x<=0||n*6<x||((x/n)==0)) {
    		return new int[] {};
		}
			
    	int arr[]=new int[n];
    	
		int p=x/n,q=x%n;
    	for(i=0;i<n;i++)  {
		
    		arr[i]=p+(q>0?1:0);
    		q--;
    	}
    	return arr;
    }
}
class Solution {
public:
    vector<int> missingRolls(vector<int>& rolls, int mean, int n) {
        int size=rolls.size(),sum=accumulate(rolls.begin(),rolls.end(),0),missingSum=0;
         missingSum=mean*(n+size)-sum;
        if(missingSum<n || missingSum>6*n)
            return {};
         int rem=missingSum%n;
         vector<int>ans(n,missingSum/n);
        for(int i=0;i<rem;i++)
            ans[i]+=1;
        return ans;   
    }
};
var missingRolls = function(rolls, mean, n) {
    let res = [];
    let sum = ((n + rolls.length) * mean) - rolls.reduce((a,b)=>a+b);
    if(sum>6*n || sum<1*n) return res;
    let dec = sum % n;
    let num = Math.floor(sum / n);
    for(let i = 0; i < n; i++){
        if(dec) res.push(num+1), dec--;
        else res.push(num);
    }
    return res;
};
Find Missing Observations