Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Add Two Numbers

Medium

Topics
Linked ListMathRecursion

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, one digit per node. Add the two numbers and return the sum as a linked list, also in reverse order.

Example 1

Input:  l1 = [2,4,3], l2 = [5,6,4]
Output: [7,0,8]
Explanation: 342 + 465 = 807.

Example 2

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

Constraints

  • 1 <= list length <= 100
  • 0 <= Node.val <= 9
  • No leading zeros except the number 0 itself.
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access