In C++, we can quickly find array sum using accumulate()
Sum of vector
We can also use a custom function in accumulate. Refer numeric header in C++ STL | Set 1 (accumulate() and partial_sum()) for details.
This article is contributed by kartik. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Find original array from encrypted array (An array of sums of other elements)
- Find an element in array such that sum of left array is equal to sum of right array
- Minimum cost to reach end of array array when a maximum jump of K index is allowed
- Print modified array after multiple array range increment operations
- Maximize the size of array by deleting exactly k sub-arrays to make array prime
- Generate original array from an array that store the counts of greater elements on right
- Minimum number greater than the maximum of array which cannot be formed using the numbers in the array
- Find minimum value to assign all array elements so that array product becomes greater
- Count number of permutation of an Array having no SubArray of size two or more from original Array
- Check if there exist two elements in an array whose sum is equal to the sum of rest of the array
- Longest alternating sub-array starting from every index in a Binary Array
- Kth smallest element in the array using constant space when array can't be modified
- Given a sorted array and a number x, find the pair in array whose sum is closest to x
- Sort an array where a subarray of a sorted array is in reverse order
- Rearrange the array to maximize the number of primes in prefix sum of the array