Practice Find Missing Observations
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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.
Source: Find Missing Observations on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
rolls = [3,2,4,3], mean = 4, n = 2
[6,6]
# Example 2
rolls = [1,5,6], mean = 3, n = 4
[2,3,2,2]
# Example 3
rolls = [1,2,3,4], mean = 6, n = 4
[]
Constraints
Related LeetCode Problems
Practice more problems similar to Find Missing Observations.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.