Sum of Big integers
You have been given two integers ‘NUM1’ and ‘NUM2’ as a string. Your task is to print the sum of both the numbers.
Input Format:
The first line contains a single integer ‘T’ representing the number of test cases. The 'T' test cases are as follows:
The only line of each test case contains two space-separated integers ‘NUM1’ and ‘NUM2’ representing two integers whose sum you need to return. As numbers are pretty large ‘NUM1’ and ‘NUM2’ will be provided as strings.
Note:
You do not need to print anything; it has already been taken care of. Just implement the function.
Output Format:
For each test case, print the sum of two numbers.
Constraints:
1 <= T <= 10000
1 <= NUM1 <= 10^50
1 <= NUM2 <= 10^50
Where ‘T’ is the number of test cases. ‘NUM1’ and ‘NUM2’ are the numbers whose sum you have to compute.
Time Limit: 1sec
Vaishu Sumthankar
2y
Using Strings. Let us store ‘NUM1’ and ‘NUM2’ as strings rather than storing them as integers. We will calculate the sum as follows: We will add zeroes before the smaller string among ‘NUM1’ and ...
Help your peers!
Add answer anonymously...
Top Amazon Program Analyst interview questions & answers
Popular interview questions of Program Analyst
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app