About 1,540,000 results
Open links in new tab
  1. algorithm - Summing an Array and Big O Notation - Stack Overflow

    Oct 12, 2012 · In 2025 if you're using python, it offers a built in function sum(). arr = [1,2,3,4,5] sum_of_elements = sum(arr) since it iterates through all the n-elements for making sum, the …

  2. Program to find sum of elements in a given array

    Sep 20, 2024 · Given an array of integers, find the sum of its elements. Examples: Input : arr[] = {1, 2, 3} Output : 6 Explanation: 1 + 2 + 3 = 6. Input : arr[] = {15, 12, 13, 10} Output : 50. Sum …

  3. Finding best algorithm for sum of a section of an array's values

    Oct 18, 2019 · Given an array of n integers in the locations A[1], A[2], …, A[n], describe an O(n^2) time algorithm to compute the sum A[i] + A[i+1] + … + A[j] for all i, j, 1 ≤ i < j ≤ n. I've tried …

  4. Maximum Subarray Sum – Kadane’s Algorithm | GeeksforGeeks

    Feb 28, 2025 · The idea of Kadane’s algorithm is to traverse over the array from left to right and for each element, find the maximum sum among all subarrays ending at that element. The …

  5. Sum of array elements using recursion - GeeksforGeeks

    Mar 17, 2025 · Given A = [1, 2, 3, 4, 5], the problem is solved recursively by breaking it down step by step. Each step reduces the array size, summing the last element with the sum of the …

  6. fast algorithm of finding sums in array - Stack Overflow

    Let's call your original array X, which contains integers x_1, ..., x_n. We want to find indices i, j, k such that x_i + x_j = x_k. Find the minimum u and maximum v of X in O(n) time. Let u' be …

  7. C Program to Calculate the Sum of the Elements in an Array

    Algorithm to calculate the sum of the elements in an array. 1. Take input of an array A [] and the size n. 2. Set i = 0 and sum = 0. 3. Perform sum = sum + A [i] 4. Perform i = i + 1. 5. If i < n, go …

  8. Array Sum - GeeksforGeeks

    Oct 16, 2023 · In context of Computer Science, array sum is defined as the sum of all the elements in an array. Suppose you have an array ARR []= {a1, a2, a3..., an}, let ArrSum be …

  9. Algorithm to calculate sum of elements of specific range in an array

    Sep 7, 2017 · A simple solution is to run a loop from l to r and calculate sum of elements in given range. The operation takes O(n) time . Another solution is to create another array and store …

  10. sum of array with O (1) - Computer Science Stack Exchange

    Apr 28, 2021 · I have an array of n elements. Smallest element that exists in the array is x and the largest element is x+n. None of the numbers between x to x + n is missing from the array. i …

  11. Some results have been removed
Refresh