Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 70127c7

Browse files
author
Ram swaroop
committed
add nos in linked list: to be done
1 parent fd6e6ca commit 70127c7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/me/ramswaroop/linkedlists/AddNumbersInTwoLists.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,29 @@ public static SingleLinkedList<Integer> add(SingleLinkedList<Integer> list1,
6363
return resultList;
6464
}
6565

66+
/**
67+
* Adds two numbers represented by two linked lists {@param list1}
68+
* and {@param list2} (where first node is the most significant
69+
* digit) and stores them in another list.
70+
* <p/>
71+
* Example:
72+
* <p/>
73+
* Input:
74+
* First List: 5->6->3 // represents number 563
75+
* Second List: 8->4->2 // represents number 842
76+
* Output:
77+
* Resultant list: 1->4->0->5 // represents number 1405
78+
* <p/>
79+
* Input:
80+
* First List: 7->5->9->4->6 // represents number 75946
81+
* Second List: 8->4 // represents number 84
82+
* Output:
83+
* Resultant list: 7->6->0->3->0 // represents number 76030
84+
*
85+
* @param list1
86+
* @param list2
87+
* @return
88+
*/
6689
public static SingleLinkedList<Integer> add_V1(SingleLinkedList<Integer> list1,
6790
SingleLinkedList<Integer> list2) {
6891
return null;

0 commit comments

Comments
 (0)