10. Find the Average
EasyArrays~6 min
Return the average (mean) of an array of numbers, rounded to two decimal places.
If the array is empty, return 0.
Examples
Example 1
- Input:
- numbers = [1, 2, 3, 4]
- Output:
- 2.5
Example 2
- Input:
- numbers = [10, 20, 25]
- Output:
- 18.33
- Why:
- 55 / 3 = 18.333..., rounded to 18.33.
Constraints
0 <= numbers.length <= 1000Round to exactly two decimal places.