You have to write a function called addLinkedLists which will add two integers, represented using reversed linked lists.
The linked lists are represented using the following structure:
typedef struct node{ int val; struct node *next; } node_t;
Examples of use
addLinkedLists(1->2->3->NULL, 2->3->4->NULL)
, the first linked list represent321
while the second represent432
. If we add these numbers, we obtain753
, the function must thus return3->5->7->NULL
addLinkedLists(9->9->9->NULL, 1->NULL)
, the first linked list represent999
while the second represent1
. If we add these numbers, we obtain1000
, the function must thus return0->0->0->1->NULL
addLinkedLists(5->9->2->NULL, 1->2->2->4->NULL)
, the first linked list represent295
while the second represent4221
. If we add these numbers, we obtain4516
, the function must thus return6->1->5->4->NULL