1093. Statistics from a Large Sample
https://leetcode.com/problems/statistics-from-a-large-sample
Description
You are given a large sample of integers in the range [0, 255]
. Since the sample is so large, it is represented by an array count
where count[k]
is the number of times that k
appears in the sample.
Calculate the following statistics:
minimum
: The minimum element in the sample.maximum
: The maximum element in the sample.mean
: The average of the sample, calculated as the total sum of all elements divided by the total number of elements.median
:If the sample has an odd number of elements, then the
median
is the middle element once the sample is sorted.If the sample has an even number of elements, then the
median
is the average of the two middle elements once the sample is sorted.
mode
: The number that appears the most in the sample. It is guaranteed to be unique.
Return the statistics of the sample as an array of floating-point numbers [minimum, maximum, mean, median, mode]
. Answers within 10-5
of the actual answer will be accepted.
Example 1:
Example 2:
Constraints:
count.length == 256
0 <= count[i] <= 109
1 <= sum(count) <= 109
The mode of the sample that
count
represents is unique.
ac
Last updated