Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6376
@mb1973 5604
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Sum of two numbers represented as arrays
Easy Accuracy: 34.18% Submissions: 804 Points: 2

Given two numbers represented by two different arrays A and B. The task is to find the sum array. The sum array is an array representation of addition of two input arrays.

Example 1:

Input:
N = 3, M = 3
A[] = {5, 6, 3}
B[] = {8, 4, 2}
Output: 1 4 0 5
Explanation: As 563 + 842 = 1405.

Example 2:

Input:
N = 6, M = 4 
A[] = {2, 2, 7, 5, 3, 3}
B[] = {4, 3, 3, 8}
Output: 2 3 1 8 7 1
Explanation: As 227533 + 4338 = 231871.

Your Task:  
You don't need to read input or print anything. Your task is to complete the function findSum() which takes the array(vector) of integers and as parameters and returns an array denoting the answer.

Expected Time Complexity: O(max(N, M))
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ N ≤ M ≤ 106
0 ≤ Ai, B≤ 9
No leading zeroes in array A and B.

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Sum of two numbers represented as arrays

Output Window