We sampled integers between 0 and 255, and stored the results in an array count:  count[k] is the number of integers we sampled equal to k.
Return the minimum, maximum, mean, median, and mode of the sample respectively, as an array of floating point numbers.  The mode is guaranteed to be unique.
(Recall that the median of a sample is:
The middle element, if the elements of the sample were sorted and the number of elements is odd;
The average of the middle two elements, if the elements of the sample were sorted and the number of elements is even.)
Example 1:
Input: count = [0,1,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Output: [1.00000,3.00000,2.37500,2.50000,3.00000]
Example 2:
Input: count = [0,4,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Output: [1.00000,4.00000,2.18182,2.00000,1.00000]
Constraints:
count.length == 256
1 <= sum(count) <= 10^9
The mode of the sample that count represents is unique.
Answers within 10^-5 of the true value will be accepted as correct.
class Solution:
    def sampleStats(self, count: List[int]) -> List[float]:
        mini = -1
        maxi = 0.0
        mode = 0.0
        biggest = 0
        total = sum(count)
        mid = total // 2 if total != 1 else 1
        median = 0.0
        accumulator = 0
        tally = 0
        nums = 0
        
        for i, num in enumerate(count):
            if not num:
                continue
            else:
                maxi = float(i)
                tally += num*i
                
            if mini == -1 and num:
                mini = float(i)
            if num > biggest:
                biggest = num
                mode = float(i)
            
            if total % 2:  # odd
                if accumulator < mid and (accumulator + num) >= mid:
                    median = float(i)
            else:          # even
                if accumulator < mid-1 and (accumulator + num) >= mid-1:
                    median = float(i)
                elif num and accumulator == mid:
                    median = (median+i)/2
            accumulator += num
        return [mini, maxi, tally/accumulator, median, mode]

class Solution:
    def sampleStats(self, count: List[int]) -> List[float]:
        mini = -1
        maxi = 0.0
        mode = 0.0
        biggest = 0
        total = sum(count)
        mid = total // 2 if total != 1 else 1
        median = 0.0
        accumulator = 0
        tally = 0
        nums = 0
        
        for i, num in enumerate(count):
            if not num:
                continue
            else:
                maxi = float(i)
                tally += num*i
                
            if mini == -1 and num:
                mini = float(i)
            if num > biggest:
                biggest = num
                mode = float(i)
            
            if total % 2:  # odd
                if accumulator < mid and (accumulator + num) >= mid:
                    median = float(i)
            else:          # even
                if accumulator < mid-1 and (accumulator + num) >= mid-1:
                    median = float(i)
                elif num and accumulator == mid:
                    median = (median+i)/2
            accumulator += num
        return [mini, maxi, tally/accumulator, median, mode]
