Sum of array elements
Java
Easy
5 views
Problem Description
Task: return sum of all elements in the array.
Output Format
Return value
Constraints
Use long to avoid overflow when needed.
Official Solution
static long sumArray(int[] a){long s=0;for(int x:a) s+=x;return s;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!