Implement the function to return the total sum of all elements. The input is a Python list of integers, and the output must be a single integer. Return 0 for an empty array.
Constraints
0 <= nums.length <= 100000
-10^9 <= nums[i] <= 10^9
Return the exact integer sum of all elements
Function Signature
defsum_array(nums):
Interviewer
Your question is Sum an Array. 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.