Given an array of N integers. Your task is to print the sum of all of the integers.
 
Example 1:
Input:
4
1 2 3 4
Output:
10
 
Example 2:
Input:
6
5 8 3 10 22 45
Output:
93
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function getSum() which takes the array A[] and its size N as inputs and returns the sum of array in a new line.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
 
Constraints:
1 ≤ N ≤ 10^{6}
0 ≤ Arr[i] ≤ 200

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3



class Solution:

    def getSum(self, arr, n):

        # Your code goes here

    

    



Solutions:
class Solution:

	def getSum(self, arr, n):
		sum = 0
		for num in arr:
			sum += num
		return sum


class Solution:

	def getSum(self, arr, n):
		c = 0
		for i in range(n):
			c = c + arr[i]
		return c


class Solution:

	def getSum(self, arr, n):
		return sum(arr)


class Solution:

	def getSum(self, arr, n):
		s = 0
		for i in arr:
			s = s + i
		return s


import math

class Solution:

	def getSum(self, arr, n):
		sum = 0
		for i in arr:
			sum = sum + i
		return sum


class Solution:

	def getSum(self, arr, n):
		sum_of_num = 0
		if n > 0:
			for i in arr:
				sum_of_num += i
		return sum_of_num


class Solution:

	def getSum(self, arr, n):
		sum = 0
		for (i, v) in enumerate(arr):
			sum = sum + arr[i]
		return sum


class Solution:

	def getSum(self, arr, n):
		count = 0
		for i in range(1, n + 1):
			count += i
		return sum(arr)


class Solution:

	def getSum(self, arr, n):
		lst = list(arr)
		sum = 0
		for i in range(len(lst)):
			sum = sum + lst[i]
		return sum


import numpy as np

class Solution:

	def getSum(self, arr, n):
		s = np.sum(arr)
		return s


class Solution:

	def getSum(self, arr, n):
		i = 0
		sum = 0
		while i < n:
			sum = sum + arr[i]
			i = i + 1
		return sum


class Solution:

	def getSum(self, arr, n):
		sum = 0
		a = list(arr)
		for i in a:
			sum += i
		return int(sum)


class Solution:

	def getSum(self, arr, n):
		count = 0
		for n in arr:
			count += n
		return count


class Solution:

	def getSum(self, arr, n):
		val = 0
		for i in range(len(arr)):
			val += arr[i]
		return val


class Solution:

	def getSum(self, arr, n):
		b = 0
		a = 0
		while b < n:
			a = a + arr[b]
			b += 1
		return a