{"id":4447,"date":"2021-08-30T08:48:15","date_gmt":"2021-08-30T08:48:15","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=4447"},"modified":"2022-11-21T08:01:19","modified_gmt":"2022-11-21T08:01:19","slug":"compare-two-strings-represented-as-linked-lists","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/","title":{"rendered":"Compare two strings represented as linked lists"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png\" alt=\"\" \/><\/p>\n<p>Till now we have seen how the linked lists can actually be implemented. In this article we are going to see how the linked lists or strings can be compared. Let&#8217;s just see how to compare two linked lists or how to compare two strings, if the first linked list is lexicographically greater, and return -1 if the second string is lexicographically greater.<\/p>\n<ul>\n<li><strong>Lexicographical order<\/strong> means alphabetical order. Character c comes after character a in alphabetical order, which means c is lexicographically greater than a.<\/li>\n<\/ul>\n<h2>How to Compare Two Strings represented as Linked Lists<\/h2>\n<p>According to the problem statement, we have to return 0 if both the linked list is the same, 1 if the first linked list is lexicographically greater, and -1 if the second linked list is lexicographically greater.<\/p>\n<p>So that means we will have to compare both the strings represented as a linked list, character by character, to check whether they are the same or not. If they are not the same, we will have to figure out which one is lexicographically greater. So below are the possible cases.<\/p>\n<ul>\n<li>If both strings are the same, then return 0, i.e., If every character of both <a href=\"https:\/\/prepbytes.com\/blog\/recursion-interview-programming\/longest-palindromic-substring-2\/\" title=\"strings matches\">strings matches<\/a>.<\/li>\n<li>There can be cases when both the strings are not the same, so we have to compare the first non-matching character of both the strings. If the first string\u2019s character comes before the second string\u2019s character in alphabetical order, then return -1; otherwise, return 1.<\/li>\n<\/ul>\n<p>Let\u2019s take some examples to understand this problem well by referring some websites to learn coding.<\/p>\n<p>Suppose the given linked lists are:<br \/>\nL1 =  a\u2192b\u2192c\u2192e<br \/>\nL2 = a\u2192b\u2192e\u2192f<\/p>\n<ul>\n<li>Now we can see that the first two nodes of both the linked list are the same and the third node of linked list L2 is greater than the third node of linked list L1. So it means that our linked list L1 is lexicographically smaller than the linked list L2, so we will output -1.<\/li>\n<\/ul>\n<p><strong>Output:<\/strong> -1<br \/>\nIf the given linked list is:<br \/>\nL1 = a\u2192b\u2192c\u2192d<br \/>\nL2 = a\u2192b\u2192b\u2192d<\/p>\n<ul>\n<li>Now we can see that the first two nodes of both L1 and L2 are the same, but the third node of L1 is lexicographically greater than the third node of L2, so we will output 1.<\/li>\n<\/ul>\n<p><strong>Output:<\/strong> 1<\/p>\n<p>Some more examples<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-1-12.png\" alt=\"\" \/><\/p>\n<p><strong>Output:<\/strong> -1<\/p>\n<p>Input: L1 = x\u2192e\u2192a\u2192k\u2192c, L2 = x\u2192e\u2192a\u2192k\u2192a<\/p>\n<p><strong>Output:<\/strong> 1<\/p>\n<p>Input: L1 = p\u2192r\u2192e\u2192p, L2 = p\u2192r\u2192e\u2192p<\/p>\n<p><strong>Output:<\/strong> 0<\/p>\n<p>I hope from the above examples the problem is clear, and now the main question is how we should approach this problem?<\/p>\n<p>Before jumping to the approach section, try to think about how you will approach it.<\/p>\n<p>Let us have a glance at the approach.<\/p>\n<h2>Approach on how to compare two linked lists<\/h2>\n<p>The idea is to start traversing through both the lists simultaneously and comparing each node of the linked lists.<\/p>\n<ul>\n<li>If the node\u2019s data of both lists matches, then move forward in the lists because at this moment, we can\u2019t decide whether the linked lists are the same or not.<\/li>\n<li>If at any point the data in the nodes of the lists do not match, then check which list has a lexicographical greater current node, if it is the first list then return 1 else, return -1.<\/li>\n<li>If both lists come to an end simultaneously, it shows that both the linked list are the same, so we will return 0.<\/li>\n<li>Otherwise, check If the first list reached the end, but the second didn\u2019t, then return -1 because this is possible only when the second list is larger in size than the first list.<\/li>\n<li>And return 1 when the second list reached the end, but the first didn\u2019t.<\/li>\n<\/ul>\n<h2>Algorithm  on how to compare two linked lists<\/h2>\n<ul>\n<li>Start traversing through both lists simultaneously.<\/li>\n<li>Compare every node\u2019s data of both the strings, if both match then, moves forward in both the lists.<\/li>\n<li>If the node\u2019s data is not the same, there is no need to move forward because we can decide here which string is lexicographically greater and return 1 or -1 by comparing the node\u2019s data.<\/li>\n<li>Stop when both or either of the lists has reached the end.<\/li>\n<li>If both reach the end at the same time, return 0.<\/li>\n<li>If the first string reached the end, but the second string did not, then return -1 else, return 1.<\/li>\n<\/ul>\n<h3>Dry Run on how to compare two linked lists<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Compare-two-strings-represented-as-linked-lists-1.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Compare-two-strings-represented-as-linked-lists-2.png\" alt=\"\" \/><\/p>\n<h2>Code Implementation  on how to compare two linked lists<\/h2>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_4449 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_4449 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_4449 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_4449 .wpsm_nav-tabs > li.active > a, #tab_container_4449 .wpsm_nav-tabs > li.active > a:hover, #tab_container_4449 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_4449 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_4449 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_4449 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_4449 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_4449 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_4449 .wpsm_nav-tabs > li > a:hover , #tab_container_4449 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_4449 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_4449 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_4449 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_4449 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_4449 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_4449 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_4449 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_4449 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_4449 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_4449 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_4449 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_4449\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_4449\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4449_1\" aria-controls=\"tabs_desc_4449_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4449_2\" aria-controls=\"tabs_desc_4449_2\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C++<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4449_3\" aria-controls=\"tabs_desc_4449_3\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_4449_4\" aria-controls=\"tabs_desc_4449_4\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_4449\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_4449_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include<stdio.h>\r\n#include<stdlib.h>\r\n\r\nstruct Node\r\n{\r\n    char c;\r\n    struct Node *next;\r\n};\r\n  \r\n\/\/ Function to create newNode in a linkedlist\r\nstruct Node* newNode(char c)\r\n{\r\n    struct Node* temp = (struct Node*)malloc(sizeof(struct Node));\r\n    temp->c = c;\r\n    temp->next = NULL;\r\n    return temp;\r\n};\r\n \r\nint compare(struct Node *list1,struct  Node *list2)\r\n{   \r\n    \/\/ Traverse both lists. Stop when\r\n    \/\/ either end of a linked list is reached\r\n    \/\/ or current characters don't match\r\n    while (list1 && list2 &&\r\n           list1->c == list2->c)\r\n    {        \r\n        list1 = list1->next;\r\n        list2 = list2->next;\r\n    }\r\n     \r\n    \/\/ If both lists are not empty,\r\n    \/\/ compare mismatching characters\r\n    if (list1 && list2)\r\n        return (list1->c > list2->c)? 1: -1;\r\n \r\n    \/\/ If either of the two lists\r\n    \/\/ has reached end\r\n    if (list1 && !list2) return 1;\r\n    if (list2 && !list1) return -1;\r\n     \r\n    \/\/ If none of the above conditions is true,\r\n    \/\/ both lists have reached end\r\n    return 0;\r\n}\r\n \r\n\/\/ Driver code\r\nint main()\r\n{\r\n    struct Node *list1 = newNode('g');\r\n    list1->next = newNode('e');\r\n    list1->next->next = newNode('e');\r\n    list1->next->next->next = newNode('k');\r\n    list1->next->next->next->next =\r\n        newNode('s');\r\n    list1->next->next->next->next->next =\r\n        newNode('b');\r\n \r\n    struct Node *list2 = newNode('g');\r\n    list2->next = newNode('e');\r\n    list2->next->next = newNode('e');\r\n    list2->next->next->next = newNode('k');\r\n    list2->next->next->next->next =\r\n        newNode('s');\r\n    list2->next->next->next->next->next =\r\n        newNode('a');\r\n    int ans = compare(list1, list2);\r\n    printf(\"%d\",ans);\r\n    \r\n    return 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_4449_2\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"cpp\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include <bits stdc++.h=\"\">\r\nusing namespace std;\r\n\r\nclass Node{\r\npublic:\r\n    char data;\r\n    Node* next;\r\n    Node(char data){\r\n        this->data = data;\r\n        this->next = NULL;\r\n    }\r\n};\r\n\r\nint compareString(Node* string1, Node* string2){\r\n\r\n    while(string1 != NULL && string2 != NULL && string1->data == string2->data){\r\n        string1 = string1->next;\r\n        string2 = string2->next;\r\n    }\r\n\r\n\r\n    \/\/ if the list are different in size and \r\n   \/\/  both have not reached to the end\r\n    if(string1 != NULL && string2 != NULL) {\r\n         return (string1->data > string2->data ? 1 : -1);\r\n    }\r\n\r\n    \/\/ if either of the list has reached end\r\n    if(string1 != NULL && string2 == NULL){\r\n         return 1;\r\n    }\r\n\r\n    if(string1 == NULL && string2 != NULL){\r\n        return -1;\r\n    }\r\n\r\n    \/\/ If both the string is same\r\n    return 0;\r\n}\r\n\r\nNode** push(Node **head_ref, char new_data)\r\n{\r\n    Node* new_node = new Node(new_data);\r\n    new_node->next = *(head_ref);\r\n    *(head_ref) = new_node;\r\n    return head_ref;\r\n}\r\n\r\nint main()\r\n{\r\n\r\n    Node *head1 = NULL, *head2 = NULL;\r\n    push(&head1, 'a');\r\n    push(&head1, 'x');\r\n    push(&head1, 'a');\r\n    push(&head1, 'p');\r\n    push(&head1, 'p');\r\n\r\n    push(&head2, 's');\r\n    push(&head2, 'x');\r\n    push(&head2, 'a');\r\n    push(&head2, 'p');\r\n    push(&head2, 'p');\r\n\r\n    cout <<  compareString(head1, head2) << endl;\r\n    return 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_4449_3\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nclass LinkedList {\r\n\r\n    Node head; \/\/ head of list\r\n    static Node a;\r\n    static Node b;\r\n    static class Node {\r\n\r\n        char data;\r\n        Node next;\r\n\r\n        Node(char d) {\r\n            data = d;\r\n            next = null;\r\n        }\r\n    }\r\n\r\n    static int compare(Node node1, Node node2) {\r\n\r\n        if (node1 == null && node2 == null) {\r\n            return 1;\r\n        }\r\n        while (node1 != null && node2 != null && node1.data == node2.data) {\r\n            node1 = node1.next;\r\n            node2 = node2.next;\r\n        }\r\n\r\n        \/\/ if the list are different in size\r\n        if (node1 != null && node2 != null) {\r\n            return (node1.data > node2.data ? 1 : -1);\r\n        }\r\n\r\n        \/\/ if either of the list has reached end\r\n        if (node1 != null && node2 == null) {\r\n            return 1;\r\n        }\r\n        if (node1 == null && node2 != null) {\r\n            return -1;\r\n        }\r\n        return 0;\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n\r\n\r\n\r\n        LinkedList.a = new Node('a');\r\n        LinkedList.a.next = new Node('x');\r\n        LinkedList.a.next.next = new Node('a');\r\n        LinkedList.a.next.next.next = new Node('p');\r\n        LinkedList.a.next.next.next.next = new Node('p');\r\n\r\n        LinkedList.b = new Node('s');\r\n        LinkedList.b.next = new Node('x');\r\n        LinkedList.b.next.next = new Node('a');\r\n        LinkedList.b.next.next.next = new Node('p');\r\n        LinkedList.b.next.next.next.next = new Node('p');\r\n\r\n        int value;\r\n        value = LinkedList.compare(a, b);\r\n        System.out.println(value);\r\n\r\n    }\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_4449_4\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"python\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nclass Node:\r\n    def __init__(self, key):\r\n        self.data = key ;\r\n        self.next = None\r\n\r\ndef compareString(head1, head2):\r\n    \r\n    while(head1 and head2 and head1.data == head2.data):\r\n        head1 = head1.next\r\n        head2 = head2.next\r\n\r\n    # if the head are different in size and \r\n    # both have not reached to the end\r\n    if(head1 and head2):\r\n        return 1 if head1.data > head2.data else -1\r\n\r\n    # If either of the two heads has reached end\r\n    if (head1 and not head2):\r\n        return 1\r\n\r\n    if (head2 and not head1):\r\n        return -1\r\n\r\n    # If both the string is same\r\n    return 0\r\n\r\ndef push(head, data):\r\n    new_node = Node(data)\r\n    new_node.next = head\r\n    head = new_node\r\n    return head\r\n\r\nhead1 = Node('a')\r\nhead1 = push(head1,'x')\r\nhead1 = push(head1,'a')\r\nhead1 = push(head1,'p')\r\nhead1 = push(head1,'p')\r\n\r\n\r\nhead2 = Node('s')\r\nhead2 = push(head1,'x')\r\nhead2 = push(head1,'a')\r\nhead2 = push(head1,'p')\r\nhead2 = push(head1,'p')\r\n\r\n\r\nprint (compareString(head1, head2))\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_4449 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_4449 a\"),jQuery(\"#tab-content_4449\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<pre><code>Output: -1<\/code><\/pre>\n<p><strong>Space complexity:<\/strong> O(1), No extra space used.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>So, In this article, We tried to understand how strings can be represented as linked lists and how we compared them lexicographically.As we have already understood that lexicographically means it&#8217;s a dictionary order. So, it is a kind of sorting. Click on the link to get more coding questions on <a href=\"https:\/\/mycode.prepbytes.com\/interview-coding\/practice\/linked-list\" title=\"linked list.\">linked list.<\/a><\/p>\n<h2>FAQs<\/h2>\n<p><strong>1. What is Lexicographic representation or lexicographic order?<\/strong><br \/>\nIt is nothing but the dictionary order where the words are ordered alphabetically.<\/p>\n<p><strong>2. Can we use == to compare the strings in java?<\/strong><br \/>\nWe can use equals() method to compare. We shouldn&#8217;t use == because they compare the reference string.<\/p>\n<p><strong>3. How do you compare objects in Java?<\/strong><br \/>\nTo compare the objects we can use equality operator (==). The equality operator can be used to compare two or more objects.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Till now we have seen how the linked lists can actually be implemented. In this article we are going to see how the linked lists or strings can be compared. Let&#8217;s just see how to compare two linked lists or how to compare two strings, if the first linked list is lexicographically greater, and return [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[125],"tags":[],"class_list":["post-4447","post","type-post","status-publish","format-standard","hentry","category-linked-list"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linked List | Compare two strings represented as linked lists | Prepbytes<\/title>\n<meta name=\"description\" content=\"Learn the most efficient way to compare two strings represented as linked lists. This blog explains how to Compare two strings represented as linked lists.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linked List | Compare two strings represented as linked lists | Prepbytes\" \/>\n<meta property=\"og:description\" content=\"Learn the most efficient way to compare two strings represented as linked lists. This blog explains how to Compare two strings represented as linked lists.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-30T08:48:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-21T08:01:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png\" \/>\n<meta name=\"author\" content=\"PrepBytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"PrepBytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/\"},\"author\":{\"name\":\"PrepBytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\"},\"headline\":\"Compare two strings represented as linked lists\",\"datePublished\":\"2021-08-30T08:48:15+00:00\",\"dateModified\":\"2022-11-21T08:01:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/\"},\"wordCount\":903,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/\",\"name\":\"Linked List | Compare two strings represented as linked lists | Prepbytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png\",\"datePublished\":\"2021-08-30T08:48:15+00:00\",\"dateModified\":\"2022-11-21T08:01:19+00:00\",\"description\":\"Learn the most efficient way to compare two strings represented as linked lists. This blog explains how to Compare two strings represented as linked lists.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linked list articles\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/linked-list\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Compare two strings represented as linked lists\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\",\"name\":\"PrepBytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"caption\":\"PrepBytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linked List | Compare two strings represented as linked lists | Prepbytes","description":"Learn the most efficient way to compare two strings represented as linked lists. This blog explains how to Compare two strings represented as linked lists.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/","og_locale":"en_US","og_type":"article","og_title":"Linked List | Compare two strings represented as linked lists | Prepbytes","og_description":"Learn the most efficient way to compare two strings represented as linked lists. This blog explains how to Compare two strings represented as linked lists.","og_url":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-08-30T08:48:15+00:00","article_modified_time":"2022-11-21T08:01:19+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png","type":"","width":"","height":""}],"author":"PrepBytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"PrepBytes","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/"},"author":{"name":"PrepBytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e"},"headline":"Compare two strings represented as linked lists","datePublished":"2021-08-30T08:48:15+00:00","dateModified":"2022-11-21T08:01:19+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/"},"wordCount":903,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/","url":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/","name":"Linked List | Compare two strings represented as linked lists | Prepbytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png","datePublished":"2021-08-30T08:48:15+00:00","dateModified":"2022-11-21T08:01:19+00:00","description":"Learn the most efficient way to compare two strings represented as linked lists. This blog explains how to Compare two strings represented as linked lists.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645185797309-Compare%20two%20strings-02.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/compare-two-strings-represented-as-linked-lists\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Linked list articles","item":"https:\/\/prepbytes.com\/blog\/category\/linked-list\/"},{"@type":"ListItem","position":3,"name":"Compare two strings represented as linked lists"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e","name":"PrepBytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","caption":"PrepBytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=4447"}],"version-history":[{"count":8,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4447\/revisions"}],"predecessor-version":[{"id":10660,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4447\/revisions\/10660"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=4447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=4447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=4447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}