FastPrepAverage or Zero
Problems/Average or Zero

Average or Zero

Waymo logoWaymo● EasyFULLTIMEOA
QuestionFunctionExamples

Problem statement

Source note: The source gives the function name, mean rule, and empty-input rule but omits the numeric representation, examples, and numeric bounds. The judged core task matches the visible source at about 98%.

Given a numeric array table, return its arithmetic mean.

The arithmetic mean is the sum of all values divided by the number of values. If table is empty, return 0.

Function

average(table: double[]) → double

Examples

Example 1

table = [2,4,6,8]return = 5.0

The values sum to 20. Dividing by the 4 values gives 5.

Example 2

table = []return = 0.0

The input is empty, so the required result is 0.

Example 3

table = [-1.5,2.5,5]return = 2.0

The values sum to 6. Dividing by the 3 values gives 2.

More Waymo problems

  • Fixed-Order Task Run Time With CooldownPHONE SCREEN · Seen Oct 2026
  • Fixed-Order Task Run Time With CooldownPHONE SCREEN · Seen Oct 2026
  • Reorderable Task Scheduler With CooldownPHONE SCREEN · Seen Oct 2026
All Waymo interview questionsSee Waymo hiring insights
Saved
public double average(double[] table) {
  // Write your code here.
}
Checking account…