Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Summing Array Values
00:00
5 left

Summing Array Values

EasyPython

Problem

In an Anaxi game interface, a component needs to calculate the total value of several displayed scores. Write a function that returns the sum of every number in an input array.

Formal Specification

Implement sum_numbers(nums), where nums is a list of integers. Return one integer equal to the sum of all elements. If nums is empty, return 0. The input list must not be modified.

Constraints

  • 0 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • Return 0 for an empty array
  • Do not modify nums

Function Signature

def sum_numbers(nums):
Interviewer

Your question is Summing Array Values. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.