Explanation

567.Find the Average of an Array

Easy
Given an array nums of non-negative integers, return the average of its elements as text with two decimal places. The averageAverage (Mean)The sum of the values divided by how many values there are. combines two array basics — a running sum and the array's length — with a lesson from earlier: the final division must be done in floating point, or the fractional part is lost. A wider type for the sum is a good habit too, since totals grow much faster than individual values.

Example 1:

Input: nums = [4,9,2,5]

Output: "5.00"

Example 2:

Input: nums = [1,2]

Output: "1.50"

+ 5 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ nums.length ≤ 1000
  • ●0 ≤ nums[i] ≤ 1000000

nums =

[4, 9, 2, 5]