Created
December 3, 2021 11:04
-
-
Save RaminMammadzada/e79093a3cdc124aed352d0b36340a80e to your computer and use it in GitHub Desktop.
CodeSignal-addTwoHugeNumbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You're given 2 huge integers represented by linked lists. Each linked list element is a number from 0 to 9999 that represents a number with exactly 4 digits. The represented number might have leading zeros. Your task is to add up these huge integers and return the result in the same format. | |
Example | |
For a = [9876, 5432, 1999] and b = [1, 8001], the output should be | |
solution(a, b) = [9876, 5434, 0]. | |
Explanation: 987654321999 + 18001 = 987654340000. | |
For a = [123, 4, 5] and b = [100, 100, 100], the output should be | |
solution(a, b) = [223, 104, 105]. | |
Explanation: 12300040005 + 10001000100 = 22301040105. | |
Input/Output | |
[execution time limit] 4 seconds (py3) | |
[input] linkedlist.integer a | |
The first number, without its leading zeros. | |
Guaranteed constraints: | |
0 ≤ a size ≤ 104, | |
0 ≤ element value ≤ 9999. | |
[input] linkedlist.integer b | |
The second number, without its leading zeros. | |
Guaranteed constraints: | |
0 ≤ b size ≤ 104, | |
0 ≤ element value ≤ 9999. | |
[output] linkedlist.integer | |
The result of adding a and b together, returned without leading zeros in the same format. | |
[Python 3] Syntax Tips | |
# Prints help message to the console | |
# Returns a string | |
def helloWorld(name): | |
print("This prints to the console when you Run Tests") | |
return "Hello, " + name |
Author
RaminMammadzada
commented
Dec 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment