Skip to main content

Calculate Compressed Mean

Easy
Data Structures and Algorithms
Editorial
Topics:
Array
Math

You are given an integer array quantities, where quantities[i] is the number of items in the i-th order.

Return the mean (average) number of items per order, rounded to 2 decimal places. If quantities is empty, return 0.0.

This is the array form of LeetCode 2985: there the orders arrive compressed as (item_count, order_occurrences) rows; here every order is listed individually.

Need help or want more practice?

Practise in an interviewGet AI Coach help