2028. Find Missing Observations

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2028

class Solution:
    def missingRolls(self, rolls: List[int], mean: int, n: int) -> List[int]:
        m = len(rolls)
        s = (n + m) * mean - sum(rolls)
        if s > n * 6 or s < n:
            return []
        res = [s // n] * n
        for i in range(s % n):
            res[i] += 1
        return res