Add_twoLinkedlist.cpp

pull/1019/head
Abhishek Anand 2022-10-14 20:19:32 +05:30 committed by GitHub
parent 5838a732dc
commit c6fae5ba7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,10 @@
/* In this algorithm two linked list is given in which we have to add both the linked list and store the output in another linked list.
Time Complexity: O(m+n) where m and n are the sizes of given two linked lists.
Space Complexity: O(m+n) where m and n are the size of the given two linked list.*/
#include <bits/stdc++.h>
using namespace std;
class Node
@ -162,3 +169,20 @@ int main()
return 0;
}
/*output:
The first Linked List
9-> 9-> 3-> 4-> 5-> 6-> NULL
The second Linked List
5-> 6-> 4-> 8-> NULL
The sum of the given two linked list
9-> 9-> 9-> 1-> 0-> 4-> NULL */