Codeforces и Polygon могут быть недоступны в период с 6 декабря, 22:00 (МСК) по 7 декабря, 00:00 (МСК) в связи с проведением технических работ. ×

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

Правка en1, от 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 ?

Теги linked list

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский striver_79 2018-06-22 08:57:07 526 Initial revision (published)