Sunday, September 8, 2013

Addition of integers given in two linklist.

Problem: You have two numbers represented by a linked list, where each node contains a sin-gle digit The digits are stored in reverse order, such that the 1s digit is at the head of the list Write a function that adds the two numbers and returns the sum as a linked list
EXAMPLE 
Sample Input: (3 -> 1 -> 5) + (5 -> 9 -> 2)
Sample Output: 8 -> 0 -> 8

Sample Input:
Integer 1: 1 1 5 
Integer 2: 1 9 3 
Sample Output:
Result: 2 0 9

Algorithm:

Source Code:

No comments:

Post a Comment