Geeksforgeeks

Error

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 **a **and **b **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 ≤ 10^{6}

0 ≤ A_{i}, B_{i }≤ 9

No leading zeroes in array A and B.

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

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

YesLoading...

Sum of two numbers represented as arrays

...