Average of a Fixed-Size Array
Updated
Problem statement
Given a non-empty fixed-size array of integers numbers, return its arithmetic mean.
The arithmetic mean is the sum of all values divided by the number of values.
Function
calculateAverage(numbers: int[]) → doubleExamples
Example 1
numbers = [1,2,3,4]return = 2.5The sum is 10, and 10 / 4 = 2.5.
Example 2
numbers = [7]return = 7.0A single-element array has that element as its mean.
Example 3
numbers = [-5,0,5,10]return = 2.5The values sum to 10, so the mean is 10 / 4 = 2.5.
Constraints
1 <= numbers.length <= 10^5.-10^9 <= numbers[i] <= 10^9.- The sum of all values fits in a signed 64-bit integer.
More Tesla Phone Screen questions
- Flatten a Branched List into a Doubly Linked ListPHONE SCREEN · Seen Sep 2026
- Reduce-Based Map and Filter PipelinePHONE SCREEN · Seen Sep 2026
- Resilient Fake API ClientPHONE SCREEN · Seen Sep 2026
- Merge JSON Array FieldsPHONE SCREEN · Seen Aug 2026
- KV Store with RollbackPHONE SCREEN · Seen Apr 2026
- Multi-Channel Valid ConvolutionPHONE SCREEN · Seen Oct 2024
- Course Schedule FeasibilityPHONE SCREEN · Seen Aug 2024
- Swap Even and Odd BitsPHONE SCREEN · Seen Mar 2023
- Find the Intersection Node of Two Linked ListsPHONE SCREEN · Seen Oct 2022
- Priority, Expiration, and LRU EvictionPHONE SCREEN · Seen Mar 2021
Similar questions at other companies
- Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Length of a Document Reached Through a Random TokenMercor · PHONE SCREENMercor interview questions
- Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
- Exponential Backoff DelaysWonderful · PHONE SCREEN
- One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
- Recover Document Hierarchy from IndentationReducto · PHONE SCREEN
- Average Grades per StudentHartford Financial Services · PHONE SCREENHartford Financial Services interview questions
- Through-Origin Linear RegressionMeta · PHONE SCREENMeta interview questions
Interview reports that mention this question
Tesla interview experiences
- Tesla Experienced Infrastructure SWE Interviews: 1 Experience
- Tesla Older SWE Intern Reports: 14 Experiences (Part 4 of 4)
- Tesla Embedded and SRE Intern Loops: 15 Experiences (Part 3 of 4)
- Tesla SWE and Data Intern Rounds: 10 Experiences (Part 2 of 4)
- 2017–2026 Tesla Intern OA / Interviews: 83 Experiences (Part 2 :)