886. Sum of Array Elements
Given an array arr of size n, the task is to find the sum of all the elements in the array.
Example 1:
Input: n=5, arr = [1,2,3,4,5]
Output: 15
Explanation: Sum of all the elements is 1+2+3+4+5 = 15
Example 2:
Input:Â n=6, arr = [1,2,1,1,5,1]
Output: 11
Explanation: Sum of all the elements is 1+2+1+1+5+1 = 11
Now Your Turn!
Pick the correct output for the given inputInput:Â n=3, arr = [2,1,1]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= n <= 105
- 1 <= arr[i] <= 104