Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Add Two Numbers

XPChallenge Points: 20
levelLevel: Medium

You are given two non-empty linked lists representing two non-negative integers.

·       Each node contains a single digit.

·       The digits are stored in reverse order.

Add the two numbers and return the total as a linked list in reverse order.

You can assume both numbers have no leading zeros, except when the number itself is 0.

Example 1:

Input: l1 = [4,3,2], l2 = [7,6,5]

Output: [1,0,8]

Explanation:

The numbers are 234 and 567. 234 + 567 = 801, stored in reverse as [1,0,8].

Example 2:

Input: l1 = [9,9], l2 = [1]

Output: [0,0,1]

Explanation:

99 + 1 = 100, reverse is [0,0,1].

Example 3:

Input: l1 = [5,5,5,5], l2 = [5,5,5]

Output: [0,1,1,6]

Explanation:

555 + 555 = 6110, reverse is [0,1,1,6].

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result