Average or Zero
Updated
Problem statement
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[]) → doubleExamples
Example 1
table = [2,4,6,8]return = 5.0The values sum to 20. Dividing by the 4 values gives 5.
Example 2
table = []return = 0.0The input is empty, so the required result is 0.
Example 3
table = [-1.5,2.5,5]return = 2.0The values sum to 6. Dividing by the 3 values gives 2.
More Waymo interview questions
- 2D Convolution Layer Forward PassPHONE SCREEN · Seen Dec 2026
- Multi-Head Attention Forward PassPHONE SCREEN · Seen Dec 2026
- Numerically Stable SoftmaxPHONE SCREEN · Seen Dec 2026
- Shortest Travel Time in a Grid with Traffic LightsPHONE SCREEN · Seen Nov 2026
- Fixed-Order Task Run Time With CooldownPHONE SCREEN · Seen Oct 2026
- Reorderable Task Scheduler With CooldownPHONE SCREEN · Seen Oct 2026
- Island Area and Water BoundaryPHONE SCREEN · Seen Sep 2026
- Linked Perception HistoryONSITE INTERVIEW · Seen Sep 2026
- Vehicle Maintenance Event ReadinessPHONE SCREEN · Seen Sep 2026
- Dictionary Matches from Repeated LettersONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Picked Player Who LostSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Count Valid Square PairsAuxoAI · OA
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Unique Integers That Sum to ZeroNVIDIA · OANVIDIA interview questions
- Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Maximum Student-Teacher DistanceChubb · OAChubb interview questions