Loading problem...
You are given two singly linked lists, each representing a non-negative integer. The digits within each list are arranged in reverse order, meaning the least significant digit appears first (at the head), and each node holds exactly one digit (0-9).
Your task is to compute the sum of these two numbers and return the result as a new linked list, also in reverse digit order.
Important: Neither input number contains leading zeros, except when the number itself is zero (represented as a single node with value 0).
l1 = [2,4,3]
l2 = [5,6,4][7,0,8]The lists represent 342 and 465 respectively. Adding them: 342 + 465 = 807, which is represented as [7,0,8] in reverse order.
l1 = [0]
l2 = [0][0]Both numbers are 0. Their sum is also 0.
l1 = [9,9,9,9,9,9,9]
l2 = [9,9,9,9][8,9,9,9,0,0,0,1]The lists represent 9999999 and 9999 respectively. Adding them: 9999999 + 9999 = 10009998, represented as [8,9,9,9,0,0,0,1] in reverse order.
Constraints