From 8a5e7636e531f0438cc8b90778ad60148521463b Mon Sep 17 00:00:00 2001 From: Udhay <72250606+Udhay-Brahmi@users.noreply.github.com> Date: Wed, 23 Dec 2020 08:00:01 +0530 Subject: [PATCH] Create Compare two linked lists --- Compare two linked lists | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Compare two linked lists diff --git a/Compare two linked lists b/Compare two linked lists new file mode 100644 index 0000000..4368a60 --- /dev/null +++ b/Compare two linked lists @@ -0,0 +1,16 @@ +int compare(Node *list1, Node *list2) +{ + // Code Here + string h="",j=""; + while(list1!=NULL){ + h+=list1->c; + list1=list1->next; + } + while(list2!=NULL){ + j+=list2->c; + list2=list2->next; + } + if(h==j){return 0;} + else if(h>j){return 1;} + return -1; +}