Skip to content

Commit befa3af

Browse files
committed
Added some comments
1 parent b228fa7 commit befa3af

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/com/ctci/linkedlists/SumLists.java

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
*/
99
public class SumLists {
1010

11+
/**
12+
* You have two numbers represented by a linked list, where each node contains a single digit. The digits are
13+
* stored in reverse order, such that the 1's digit is at the head of the list (or in other words, the least
14+
* significant digit is stored at the head of the list). Write a function that adds the two numbers and returns
15+
* the sum as a linked list.
16+
* <p>
17+
* EXAMPLE
18+
* Input: (7-> 1 -> 6) + (5 -> 9 -> 2).That is, 617 + 295.
19+
* Output: 2 -> 1 -> 9. That is, 912.
20+
*
21+
* @param num1
22+
* @param num2
23+
* @return
24+
*/
1125
private static Node sumLists(Node num1, Node num2) {
1226
int carry = 0;
1327
int sum;

0 commit comments

Comments
 (0)