Double a Number Represented as a Linked List
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A non-negative integer is stored in a linked list, one decimal digit per node, with the **most significant digit at the head**. There are no leading zeros except for the number 0 itself (the single node [0]).
Return the head of a linked list, in the same format, representing **twice** the number. The result may be one node longer than the input.
The list can be much longer than any built-in integer type, so work digit by digit.
Examples
Constraints
- The number of nodes is in `[1, 10^4]`.
- `0 <= Node.val <= 9`
- The input has no leading zeros except the number `0` itself.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.