Thursday, July 13, 2017

Monk and Welcome Problem-Practice Problem from Hackerearth and solution using python 2.7.6

Problem Statement:

Having a good previous year, Monk is back to teach algorithms and data structures. This year he welcomes the learners with a problem which he calls "Welcome Problem". The problem gives you two arrays A and B (each array of size N) and asks to print new array C such that:
C[i]=A[i]+B[i] ; 1iN
Now, Monk will proceed further when you solve this one. So, go on and solve it :)
Input:
First line consists of an integer N, denoting the size of A and B.
Next line consists of N space separated integers denoting the array A.
Next line consists of N space separated integers denoting the array B.
Output:
Print N space separated integers denoting the array C.
Input Constraints:
1N100000
1A[i]1000001iN
1B[i]1000001iN



Programming using python 2.7.6:

N = input()
A = map(int,raw_input().split()[:N])
B = map(int,raw_input().split()[:N])
for x in zip(A,B):print sum(x),




No comments:

Post a Comment