Given an array Arr[] of N integers.Find the sum of values of even and odd index positions separately.
Example 1:
Input:
N=5
Arr={1,2,3,4,5}
Output:
9 6
Explanation:
The sum of elements at odd places i.e
at 1st,3rd and 5th places are (1+3+5=9)
Similarly,the sum of elements at even 
places i.e. at 2nd and 4th places are
(2+4=6).
Example 2:
Input:
N=5
Arr={1,1,1,1,1}
Output:
3 2
Explanation:
The sum of elements at odd places
is (1+1+1=3).Similarly, the sum of
elements at even places is (1+1=2)
Your Task:
You don't need to read input or print anything.Your Task is to complete the function EvenOddSum() which takes an integer N and an array Arr as input parameters and returns the sum of elements in odd places and in even places separately.
 
Expected Time Complexity:O(N)
Expected Auxillary Space:O(1)
Constraints:
1<=N<=10^{5}
0<=Arr[i]<=10^{4},for 0<=i

Source: geeksforgeeks | Difficulty: EASY
Tags: Graph traversal

Starter code: #User function Template for python3

class Solution:
    def EvenOddSum(self,N,Arr):
        #code here (return list)

Solutions:
class Solution:

	def EvenOddSum(self, N, Arr):
		sum_od = 0
		sum_ev = 0
		for i in range(N):
			if i % 2 == 0:
				sum_ev += Arr[i]
			else:
				sum_od += Arr[i]
		return (sum_ev, sum_od)


class Solution:

	def EvenOddSum(self, N, Arr):
		es = 0
		os = 0
		for i in range(N):
			if i % 2 == 0:
				es += Arr[i]
			elif i % 2 != 0:
				os += Arr[i]
		return (es, os)


class Solution:

	def EvenOddSum(self, N, Arr):
		count_even = 0
		count_odd = 0
		for i in range(1, N + 1):
			if i % 2 == 0:
				count_even += Arr[i - 1]
			else:
				count_odd += Arr[i - 1]
		return [count_odd, count_even]


class Solution:

	def EvenOddSum(self, N, Arr):
		even = 0
		odd = 0
		for i in range(1, N + 1):
			if i % 2 == 0:
				even += Arr[i - 1]
			else:
				odd += Arr[i - 1]
		return [odd, even]


class Solution:

	def EvenOddSum(self, N, Arr):
		odd = 0
		even = 0
		for i in range(0, N, 2):
			odd += Arr[i]
		even = sum(Arr) - odd
		return [odd, even]


class Solution:

	def EvenOddSum(self, N, Arr):
		summ_o = 0
		summ_e = 0
		for (i, a) in enumerate(Arr):
			if i & 1:
				summ_o += a
			else:
				summ_e += a
		return (summ_e, summ_o)


class Solution:

	def EvenOddSum(self, N, Arr):
		res = []
		o_sum = 0
		e_sum = 0
		length = len(Arr)
		indexes = range(1, N, 2)
		for i in indexes:
			if i < length:
				e_sum = e_sum + Arr[i]
			if i + 2 > length:
				break
		indexes = range(0, N, 2)
		for i in indexes:
			if i < length:
				o_sum = o_sum + Arr[i]
			if i + 2 > length:
				break
		res.append(o_sum)
		res.append(e_sum)
		return res


class Solution:

	def EvenOddSum(self, N, Arr):
		a = 0
		b = 0
		for i in range(N):
			if i % 2 != 0:
				a += Arr[i]
			else:
				b += Arr[i]
		return (b, a)


class Solution:

	def EvenOddSum(self, N, Arr):
		sum = 0
		so = 0
		for i in range(N):
			if i % 2 != 0:
				sum = sum + Arr[i]
			else:
				so = so + Arr[i]
		return (so, sum)


class Solution:

	def EvenOddSum(self, N, Arr):
		eve_sum = 0
		odd_sum = 0
		for i in range(0, N):
			if i % 2 == 0:
				eve_sum = eve_sum + Arr[i]
			else:
				odd_sum = odd_sum + Arr[i]
		return (eve_sum, odd_sum)


class Solution:

	def EvenOddSum(self, N, Arr):
		x = 0
		list1 = [x + Arr[i] for i in range(0, len(Arr), 2)]
		list2 = [x + Arr[i] for i in range(1, len(Arr), 2)]
		return (sum([i for i in list1]), sum([i for i in list2]))


class Solution:

	def EvenOddSum(self, N, Arr):
		sum1 = 0
		sum2 = 0
		for i in range(N):
			if i % 2 == 0:
				sum1 += Arr[i]
			else:
				sum2 += Arr[i]
		return (sum1, sum2)


class Solution:

	def EvenOddSum(self, N, Arr):
		s0 = 0
		s1 = 0
		for i in range(N):
			if i % 2 == 0:
				s0 += Arr[i]
			else:
				s1 += Arr[i]
		return (s0, s1)


class Solution:

	def EvenOddSum(self, N, Arr):
		li = []
		esum = 0
		osum = 0
		for i in range(len(Arr)):
			if i % 2 == 0:
				esum += Arr[i]
			else:
				osum += Arr[i]
		li.append(esum)
		li.append(osum)
		return li


class Solution:

	def EvenOddSum(self, N, Arr):
		return (sum(Arr[::2]), sum(Arr[1::2]))


class Solution:

	def EvenOddSum(self, n, arr):
		odd = 0
		even = 0
		for i in range(n):
			if i % 2 == 0:
				even += arr[i]
			else:
				odd += arr[i]
		return (even, odd)


class Solution:

	def EvenOddSum(self, N, Arr):
		even_sum = 0
		odd_sum = 0
		for i in range(0, N, 2):
			even_sum += Arr[i]
		for i in range(1, N, 2):
			odd_sum += Arr[i]
		return (even_sum, odd_sum)


class Solution:

	def EvenOddSum(self, N, Arr):
		odd = 0
		even = 0
		for (idx, i) in enumerate(Arr):
			if idx % 2 != 0:
				odd += i
			else:
				even += i
		return [even, odd]


class Solution:

	def EvenOddSum(self, N, Arr):
		sumodd = 0
		sumeven = 0
		li = []
		for i in range(0, N):
			if i % 2 != 0:
				sumeven += Arr[i]
			else:
				sumodd += Arr[i]
		li.append(sumodd)
		li.append(sumeven)
		return li


class Solution:

	def EvenOddSum(self, N, Arr):
		o = 0
		e = 0
		for i in range(N):
			if i % 2 == 0:
				o += Arr[i]
			else:
				e += Arr[i]
		return (o, e)


class Solution:

	def EvenOddSum(self, N, Arr):
		oddsum = 0
		evensum = 0
		for i in range(0, N, 2):
			oddsum = oddsum + Arr[i]
		for i in range(1, N, 2):
			evensum = evensum + Arr[i]
		anslist = [0] * 2
		anslist[0] = oddsum
		anslist[1] = evensum
		return anslist


class Solution:

	def EvenOddSum(self, N, Arr):
		l1 = []
		sum = 0
		sum1 = 0
		for i in range(N):
			if i % 2 == 0:
				sum += Arr[i]
			else:
				sum1 += Arr[i]
		l1.append(sum)
		l1.append(sum1)
		return l1


class Solution:

	def EvenOddSum(self, N, Arr):
		sum_even = 0
		sum_odd = 0
		for i in range(0, N):
			if i % 2 == 0:
				sum_even += Arr[i]
			else:
				sum_odd += Arr[i]
		return (sum_even, sum_odd)


class Solution:

	def EvenOddSum(self, N, Arr):
		se = so = i = 0
		while i < N:
			if i % 2 == 0:
				se += Arr[i]
			if i % 2 != 0:
				so += Arr[i]
			i += 1
		return (se, so)


class Solution:

	def EvenOddSum(self, N, Arr):
		(x, y) = (0, 0)
		for i in range(N):
			if i % 2 == 0:
				x += Arr[i]
			else:
				y += Arr[i]
		return (x, y)


class Solution:

	def EvenOddSum(self, N, Arr):
		total_even = 0
		total_odd = 0
		data = []
		for i in range(len(Arr)):
			if i % 2 == 0:
				total_even = total_even + Arr[i]
			else:
				total_odd = total_odd + Arr[i]
		data.append(total_even)
		data.append(total_odd)
		return data


class Solution:

	def EvenOddSum(self, N, Arr):
		odd = []
		even = []
		for i in range(len(Arr)):
			if i % 2 != 0:
				odd.append(Arr[i])
			else:
				even.append(Arr[i])
		return (sum(even), sum(odd))


class Solution:

	def EvenOddSum(self, N, Arr):
		(v, k) = ([], [])
		for i in range(N):
			if i % 2 == 0:
				v.append(Arr[i])
			else:
				k.append(Arr[i])
		return (sum(v), sum(k))


class Solution:

	def EvenOddSum(self, N, Arr):
		(odd, eve) = (0, 0)
		for i in range(0, N, 2):
			odd += Arr[i]
		for i in range(1, N, 2):
			eve += Arr[i]
		return [odd, eve]


class Solution:

	def EvenOddSum(self, N, Arr):
		ev = 0
		li = []
		od = 0
		for i in range(N):
			if i % 2 == 0:
				ev += Arr[i]
			else:
				od += Arr[i]
		li.append(ev)
		li.append(od)
		return li


class Solution:

	def EvenOddSum(self, N, Arr):
		sumOdd = 0
		sumeven = 0
		i = 1
		for num in Arr:
			if i % 2 == 0:
				sumeven += num
				i += 1
			else:
				sumOdd += num
				i += 1
		return [sumOdd, sumeven]


class Solution:

	def EvenOddSum(self, N, Arr):
		r = 0
		for i in range(0, N, 2):
			r += Arr[i]
		return (r, sum(Arr) - r)


class Solution:

	def EvenOddSum(self, N, Arr):
		A = sum(Arr[::2])
		B = sum(Arr[1::2])
		return (A, B)


class Solution:

	def EvenOddSum(self, N, Arr):
		sum_list = []
		even_sum = sum(Arr[::2])
		odd_sum = sum(Arr[1::2])
		sum_list.append(even_sum)
		sum_list.append(odd_sum)
		return sum_list


import functools

class Solution:

	def EvenOddSum(self, N, Arr):
		l = [0, 0]
		for i in range(0, len(Arr)):
			if (i + 1) % 2 != 0:
				l[0] += Arr[i]
			else:
				l[1] += Arr[i]
		return l


class Solution:

	def EvenOddSum(self, N, Arr):
		sume = 0
		sumo = 0
		for i in range(len(Arr)):
			if i % 2 == 0:
				sume += Arr[i]
			else:
				sumo += Arr[i]
		return (sume, sumo)


class Solution:

	def EvenOddSum(self, N, Arr):
		l = []
		m = 0
		n = 0
		for i in range(N):
			if i % 2 == 0:
				m = m + Arr[i]
			else:
				n = n + Arr[i]
		l.append(m)
		l.append(n)
		return l


class Solution:

	def EvenOddSum(self, N, Arr):
		even = odd = 0
		for i in Arr[::2]:
			even += i
		for i in Arr[1::2]:
			odd += i
		return (even, odd)


class Solution:

	def EvenOddSum(self, n, arr):
		a = 0
		b = 0
		for i in range(n):
			if i % 2 == 0:
				a += arr[i]
			else:
				b += arr[i]
		return (a, b)


class Solution:

	def EvenOddSum(self, N, Arr):
		evenSum = 0
		oddSum = 0
		for i in range(0, N):
			if i % 2 == 0:
				evenSum += Arr[i]
			else:
				oddSum += Arr[i]
		return (evenSum, oddSum)


class Solution:

	def EvenOddSum(self, N, Arr):
		Esum = 0
		Osum = 0
		for i in range(0, N):
			if i % 2 == 0:
				Esum += Arr[i]
			else:
				Osum += Arr[i]
		return (Esum, Osum)