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

Double a Number Represented as a Linked List

Medium

Topics
Linked ListMathStack

Given the head of a non-empty linked list whose nodes store the digits of a non-negative integer in order (most significant digit first, no leading zeros except the number 0 itself), return the list representing double that number.

Example 1

Input:  head = [1,8,9]
Output: [3,7,8]
Explanation: 189 * 2 = 378.

Example 2

Input:  head = [9,9,9]
Output: [1,9,9,8]

Constraints

  • 1 <= number of nodes <= 6
  • 0 <= Node.val <= 9
  • No leading zeros except the number 0.
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