Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Array Traversal Coding

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

Your question is Array Traversal Coding. 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

Advanced World Solutions, Inc. processes sequential measurement values in memory. Given an array of integers, traverse the array from left to right and return the sum of every element.

Each element must be included exactly once. The array may contain positive numbers, negative numbers, and zero. Do not modify the input array.

Formal Specification

Implement sum_array(nums).

  • Input: nums, a list of integers.
  • Output: An integer equal to the sum of all values in nums.
  • Traversal order: Process elements from index 0 through index len(nums) - 1.

Constraints

  • 0 <= len(nums) <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • The input list must not be modified

Function Signature

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