Medium · Linked Lists

Add two numbers

Given two non-empty linked lists l1 and l2 whose nodes hold the digits (0–9) of two non-negative integers in reverse order (ones digit first), return their sum as a linked list in the same reverse-digit format.

Examples

Example 1

{
  "l1": [2, 4, 3],
  "l2": [5, 6, 4]
}

Output: [7,0,8] = 807

Example 2

{
  "l1": [9, 9],
  "l2": [1]
}

Output: [0,0,1] = 100

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Linked Lists problems