From c6fae5ba7aa6be79ebee22a16e87dc37b0b50054 Mon Sep 17 00:00:00 2001 From: Abhishek Anand <104293997+chhotu2@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:19:32 +0530 Subject: [PATCH] Add_twoLinkedlist.cpp --- .../Linked-Lists/Add-Two-linkedlist.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/algorithms/CPlusPlus/Linked-Lists/Add-Two-linkedlist.cpp b/algorithms/CPlusPlus/Linked-Lists/Add-Two-linkedlist.cpp index 3799cfe2..5bd4f1bb 100644 --- a/algorithms/CPlusPlus/Linked-Lists/Add-Two-linkedlist.cpp +++ b/algorithms/CPlusPlus/Linked-Lists/Add-Two-linkedlist.cpp @@ -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 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 */ + + + + + + + +