
Asked in Amazon
Sum of Big Integers Problem Statement
Given two integers represented as strings, 'NUM1' and 'NUM2', compute and return their sum.
Input:
T
NUM1 NUM2
...
Output:
Sum of NUM1 and NUM2 for each test case
Example:
Input:
2
123456789123456789123456789 987654321987654321987654321
1 999999999999999999999999999
Output:
1111111111111111111111111110
1000000000000000000000000000
Constraints:
1 <= T <= 10000
1 <= |NUM1| <= 1050
1 <= |NUM2| <= 1050
- Where:
T
is the number of test cases, andNUM1
andNUM2
are the numbers given as strings. - Time Limit:
1 sec

AnswerBot
4mo
Program to compute sum of big integers represented as strings.
Convert strings to integers and add them digit by digit from right to left, considering carry over.
Handle cases where one number is longer...read more
Vaishu Sumthankar
3y
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 Program Analyst Interview Questions Asked at Amazon
Q. Longest Common Prefix Problem Statement You are given an array ‘ARR’ consisting ...read more
Q. Longest Common Subsequence Problem Statement Given two strings STR1 and STR2, de...read more
Q. Closest Sum Problem Statement Given an array of integers ARR of size N and an in...read more
Interview Questions Asked to Program Analyst at Other Companies
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

