Add Two Numbers
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
Two non-negative integers are each stored as a singly linked list of decimal digits in **reverse** order: the head holds the ones digit, the next node the tens digit, and so on. Return their sum as a linked list in the same reversed format.
Neither input has leading zeros, except for the number 0 itself, which is the single-node list [0]. The result must not have leading zeros either.
The numbers can be up to 100 digits long, so converting to a built-in integer type is not a safe general approach; add digit by digit with a carry.
Examples
Constraints
- 1 <= number of nodes in each list <= 100
- 0 <= Node.val <= 9
- Inputs have 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.