Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5704 |

@Quandray | 5245 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5046 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@mantu_singh | 3530 |

@marius_valentin_dragoi | 3523 |

@sushant_a | 3459 |

Complete Leaderboard | |

Handle | Score |

@cfwong8 | 1160 |

@gurshehzadsingh | 847 |

@nithinreddy3210 | 737 |

@mohanreddy8847 | 702 |

@AkashLahoty | 606 |

@jha8768 | 583 |

@workit | 582 |

@balwanyadav34 | 582 |

@pritsahkar2000 | 580 |

@dipeshtiwari47 | 571 |

@divyagupta221100 | 557 |

Complete Leaderboard |

Given two array A[0….N-1] and B[0….M-1] of size N and M respectively, representing two numbers such that every element of arrays represent a digit. For example, A[] = { 1, 2, 3} and B[] = { 2, 1, 4 } represent 123 and 214 respectively. The task is to find the sum of both the numbers.

**Example 1:**

**Input :** A[] = {1, 2}, B[] = {2, 1}
**Output :** 33
**Explanation:**
N=2, and A[]={1,2}
M=2, and B[]={2,1}
Number represented by first array is 12.
Number represented by second array is 21
Sum=12+21=33

**Example 2:**

**Input :** A[] = {9, 5, 4, 9}, B[] = {2, 1, 4} **
Output :** 9763

**Your Task:**

This is a function problem. The input is already taken care of by the driver code. You only need to complete the function **calc_Sum()** that takes an array **(a)**, sizeOfArray **(n)**, an array **(b), **sizeOfArray **(m),** and return the sum . The driver code takes care of the printing.

**Expected Time Complexity:** O(N + M).

**Expected Auxiliary Space:** O(N + M).

**Constraints:**

2 ≤ N ≤ 10^{5}

2 ≤ M ≤ 10^{5}

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...

Add two numbers represented by two arrays

...