You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Two Lists Sum Advanced <iclass="fa fa-star"></i><iclass="fa fa-star"></i><iclass="fa fa-star"></i><iclass="fa fa-star-half-o"></i>
2
-
3
-
tags: linked list, recursion, iteration
1
+
# Two Lists Sum Advanced <iclass="fa fa-star"></i><iclass="fa fa-star"></i><iclass="fa fa-star"></i>
4
2
5
3
## Source
6
4
7
-
-GeeksforGeeks - [Add two numbers represented by linked lists | Set 2 - GeeksforGeeks](http://www.geeksforgeeks.org/sum-of-two-linked-lists/)
5
+
-CC150 - [Add two numbers represented by linked lists | Set 2 - GeeksforGeeks](http://www.geeksforgeeks.org/sum-of-two-linked-lists/)
8
6
9
7
```
10
8
Given two numbers represented by two linked lists, write a function that returns sum list.
11
9
The sum list is linked list representation of addition of two input numbers.
12
-
It is not allowed to modify the lists.
13
10
14
11
Example
15
12
16
13
Input:
17
-
First List: 5->6->3 // represents number 563
18
-
Second List: 8->4->2 // represents number 842
14
+
First List: 5->6->3 // represents number 563
15
+
Second List: 8->4->2 // represents number 842
19
16
Output
20
17
Resultant list: 1->4->0->5 // represents number 1405
21
18
22
19
Challenge
23
20
21
+
Not allowed to modify the lists.
24
22
Not allowed to use explicit extra space.
25
23
```
26
24
25
+
### 题解1 - 反转链表
26
+
27
+
在题 [Two Lists Sum | Data Structure and Algorithm](http://algorithm.yuanbin.me/linked_list/two_lists_sum.html) 的基础上改了下数位的表示方式,前者低位在前,高位在后,这个题的高位在前,低位在后。很自然地可以联想到先将链表反转,而后再使用 Two Lists Sum 的解法。
28
+
27
29
## Reference
28
30
29
31
-[Add two numbers represented by linked lists | Set 2 - GeeksforGeeks](http://www.geeksforgeeks.org/sum-of-two-linked-lists/)
0 commit comments