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, and NUM1 and NUM2 are the numbers given as strings.
  • Time Limit: 1 sec
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...
Amazon Program Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter