Help in Addition of two linked lists in O(1)

Revision en1, by striver_79, 2018-06-22 08:57:07

Given 2 Linked Lists containing single digit as data representing number with most significant digit at head and least significant at the tail return the addition of both.

The solution must not reverse the given linked lists and do it in O(n) time complexity and constant space complexity(Recursive solution will take O(n) space because of stack).

For example:

9 -> 3 -> 2 -> 2 ->

+

3 -> 4 -> 8 -> 3 ->

=

1 -> 2 -> 8 -> 0 -> 5 .

Can anyone help me out ?

Tags linked list

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English striver_79 2018-06-22 08:57:07 526 Initial revision (published)