Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Array Sum

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Find Array Sum. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

A JBL device component receives an array of integer values representing a batch of audio samples or calibration readings. Write a function that returns the sum of every value in the array.

Use a single pass through the array and do not modify the input.

Formal Specification

Implement sum_values(values):

  • Input: values, a list of integers.
  • Output: An integer equal to the sum of all elements in values.
  • For an empty list, return 0.

Constraints

  • 0 <= len(values) <= 100,000
  • -10^6 <= values[i] <= 10^6
  • The input list must remain unchanged

Function Signature

def sum_values(values):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output