Write a function array_sum(arr) that returns the sum of all elements in a numpy array without using np.sum().
Example:
Input: arr = [1, 2, 3, 4, 5]
Output: 15
Constraints:
Test Cases
Test Case 1
Input:
[1, 2, 3, 4, 5]Expected:
15Test Case 2
Input:
[10, 20, 30]Expected:
60Test Case 3
Input:
[-1, 0, 1]Expected:
0+ 2 hidden test cases
Python 3
Loading editor...
Console Output
Click "Run" to test your code or "Submit" to submit your solution.