class Solution:
def missingRolls(self, rolls: List[int], mean: int, n: int) -> List[int]:
m = len(rolls)
nTotal = (mean * (n + m)) - sum(rolls)
if nTotal < n or nTotal > n * 6:
return []
res = []
while nTotal:
dice = min(nTotal - n + 1, 6)
res.append(dice)
nTotal -= dice
n -= 1
return resWhere is the size of the array and is the number of missing observations.
class Solution:
def missingRolls(self, rolls: List[int], mean: int, n: int) -> List[int]:
m = len(rolls)
nTotal = (mean * (n + m)) - sum(rolls)
if nTotal < n or nTotal > n * 6:
return []
avg = nTotal // n
rem = nTotal - (avg * n)
return [avg] * (n - rem) + [avg + 1] * remWhere is the size of the array and is the number of missing observations.