Interview Query

Sum Numbers As Strings

Start Timer

0:00:00

Upvote
0
Downvote
Save question
Mark as completed
View comments (1)
Next question

Given two string representations of very large integers, create a Python function, string_sum, that returns the sum of these two integers as a string. Each string integer may start with a '+' or '-' sign.

Treat these strings as if they were extremely large (gigabytes in size), so usual conversion methods to integers don’t work due to memory constraints.

Example:

Input:

num1 = "+123456789"
num2 = "-987654321"

Output:

def string_sum(num1, num2) -> "-864197532"
.
.
.
.
.


Comments

Loading comments