Sum of N Integers - Even Reversed
Coding Problem Keys
Sum of N Integers - Even Reversed
Problem Statement
The program must accept N integers and print the sum S of all POSITIVE integers with the even positive integers reversed.
Boundary Condition(S)
1 <= N <= 100000
Input Format
The first line will contain N.
The second line will contain the N integers separated by a space.
Output Format
The first line will contain S.
Example Input/Output 1
Input
4
39 -8 57 24
Output
138
Explanation
The sum = 39 + 57 + 42 = 138 (The even number 24 is reversed).
Example Input/Output 2
Input
3
-23 -11 -445
Output
0
Note: Max Execution Time Limit: 5000 millisecs
Solution
Programming Language: Python 3 Language
n=int(input())
l=list(map(str,input().split()))
s=0
for i in l:
if '-' not in i:
if(int(i)%2==0):
s+=int(i[::-1])
else:
s+=int(i)
print(s)
# Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments