← 返回 amazon 的题目列表Add Two Numbers Represented by Reversed Linked Lists
类型:online_judge
amazon
Coding Question
Given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
Example:
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Because 342 + 465 = 807.
Function Signature:
def addTwoNumbers(l1: ListNode, l2: ListNode) -> ListNode:
# Implement this method
Ensure the result is stored in the correct order.
Example
Input
(2 -> 4 -> 3) + (5 -> 6 -> 4)