{"id":5237,"date":"2021-09-29T11:15:32","date_gmt":"2021-09-29T11:15:32","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=5237"},"modified":"2022-11-08T12:15:17","modified_gmt":"2022-11-08T12:15:17","slug":"subtract-two-numbers-represented-as-linked-lists","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/","title":{"rendered":"Subtract Two Numbers Represented as Linked Lists"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png\" alt=\"\" \/><br \/>\nWe already have an idea as we have solved many operations that can be performed on the linked list. In this article, we will subtract two numbers represented as linked lists. We have given two lists and we have to subtract two numbers represented as <a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/a-brief-introduction-to-linked-lists\/\">linked lists.<\/a><\/p>\n<\/p>\n<h2>How to Subtract Two Numbers as Linked Lists<\/h2>\n<p>In this problem, we are given two linked lists, <strong>L1<\/strong> and <strong>L2<\/strong>. Both <strong>L1<\/strong> and <strong>L2<\/strong> are positive numbers represented as linked lists. Our task is to subtract the smaller lists from the larger list (smaller and larger value-wise) and return the difference between the values of the list as a linked list.<\/p>\n<p>One thing that we have to note is that the input lists can be in any order, but we always need to subtract the smaller list from the larger list. It may be assumed that there are no leading zeroes in the input lists.<\/p>\n<h3>Understanding with Example<\/h3>\n<p>Let\u2019s try to understand this problem with the help of examples.<\/p>\n<p>If the list given to us be <strong>L1<\/strong> = 1 \u2192 0 \u2192 0 \u2192 NULL and <strong>L2<\/strong> = 5 \u2192 NULL.<\/p>\n<ul>\n<li>According to the problem statement, we need to subtract the smaller list from the larger list and return the difference in form of a list.<\/li>\n<li>From the input, we can clearly see that the list L1 is greater than the list L2, so we will have to subtract the list L2 from list L1.<\/li>\n<li>The numeric representation of list L1 is 100, and list L2 is 5. The difference between L1 and L2 is 95.<\/li>\n<li>Our output will be the linked list representation of the difference between L1 and L2, which will be 0 \u2192 9 \u2192 5 \u2192 NULL.<\/li>\n<\/ul>\n<p>Let\u2019s take another example to make the problem understanding more clearer. If the given lists are <strong>L1<\/strong> = 5 \u2192 2 \u2192 3 \u2192NULL and <strong>L2<\/strong> = 6 \u2192 3 \u2192 5 \u2192 NULL.<\/p>\n<ul>\n<li>In this case, we can clearly see that list L2 is greater than list L1 (value wise) and the numeric difference between L2 and L1 is <strong>635 &#8211; 523 = 112<\/strong>. <\/li>\n<li>Now our output will be the linked list representation of the difference between the numeric representation of L1 and L2, which will be 1 \u2192 1 \u2192 2 \u2192 NULL.<\/li>\n<\/ul>\n<h3>Some more examples<\/h3>\n<p>Sample Input 1: <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/input-22.png\" alt=\"\" \/><\/p>\n<p>Sample Output 1: <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/output-25.png\" alt=\"\" \/><\/p>\n<p>Sample Output 2: <strong>L1<\/strong> = 1\u21922\u21925\u21926\u2192NULL, <strong>L2<\/strong> = 3\u21924\u2192NULL<\/p>\n<p>Sample Output 2: 1\u21922\u21922\u21922\u2192NULL<\/p>\n<p>Now, I think from the above examples, the problem statement is clear. Let\u2019s see how we can approach it.<\/p>\n<p>Before moving to the approach section, try to think about how you can approach this problem.<\/p>\n<ul>\n<li>If stuck, no problem, we will thoroughly see how we can approach this problem in the next section.<\/li>\n<\/ul>\n<p>Let\u2019s move to the approach section.<\/p>\n<h2>Approach to subtract two numbers represented as linked lists<\/h2>\n<p>Our approach will be simple:<\/p>\n<ul>\n<li>First, we have to find the greater value list among the given lists. <\/li>\n<li>How we will do that:\n<ul>\n<li>If sizes of lists are different, then we know which linked list is smaller, and we&#8217;ll proceed by appending zeroes at the end of the smaller linked list. <\/li>\n<li>If the sizes of the lists are the same, then we will find the numerical values represented by both the linked lists and find the smaller linked list. <\/li>\n<\/ul>\n<\/li>\n<li>After this, we will, one by one, subtract nodes of the smaller linked list from the larger list.<\/li>\n<\/ul>\n<p>Let&#8217;s move to the algorithm section<\/p>\n<h2>Algorithm to subtract two numbers represented as linked lists <\/h2>\n<ul>\n<li>Calculate the size of the given two linked lists.\n<ul>\n<li>If sizes are not the same, append zeroes in the smaller linked list using <strong>paddZeros<\/strong> function.<\/li>\n<li>If sizes are the same, then we have to find the smaller value linked list.<\/li>\n<\/ul>\n<\/li>\n<li>Now that we know which linked list is smaller, we follow the below steps:\n<ul>\n<li>We have to one by one subtract the nodes of the smaller linked list from the larger linked list. <\/li>\n<li>We also have to keep track of <strong>borrow<\/strong> while subtracting.<\/li>\n<\/ul>\n<\/li>\n<li>Once we are done substracting, we will have our difference of <strong>L1<\/strong> and <strong>L2<\/strong> in form of linked list.<\/li>\n<\/ul>\n<h3>Dry Run for subtracting 2 numbers<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-29.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_2-29.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_3-17.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_4-11.png\" alt=\"\" \/><\/p>\n<h2>Code Implementation to Subtract 2 Numbers Represented as 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_5238 {\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_5238 .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_5238 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5238 .wpsm_nav-tabs > li.active > a, #tab_container_5238 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5238 .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_5238 .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_5238 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5238 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5238 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5238 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5238 .wpsm_nav-tabs > li > a:hover , #tab_container_5238 .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_5238 .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_5238 .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_5238 .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_5238 .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_5238 .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_5238 .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_5238 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5238 .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_5238 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5238 .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_5238 .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_5238\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5238\">\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_5238_1\" aria-controls=\"tabs_desc_5238_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_5238_2\" aria-controls=\"tabs_desc_5238_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>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\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_5238\">\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_5238_1\">\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\n\/* Node structure of a singly linked list *\/\r\nstruct Node {\r\n    int data;\r\n    struct Node* next;\r\n};\r\n\r\n\/* Using this function we will create a new node and return it *\/\r\nNode* newNode(int data)\r\n{\r\n    Node* temp = new Node;\r\n    temp->data = data;\r\n    temp->next = NULL;\r\n    return temp;\r\n}\r\n\r\n\/* Using this function we will find the length of a linked list *\/\r\nint findLength(Node* Node)\r\n{\r\n    int size = 0;\r\n    while (Node != NULL) {\r\n        Node = Node->next;\r\n        size++;\r\n    }\r\n    return size;\r\n}\r\n \r\n\/* Using this function we will be padding the smaller list (list having smaller length among the given two lists) with nodes having data = 0 *\/\r\nNode* paddZeros(Node* sNode, int diff)\r\n{\r\n    if (sNode == NULL)\r\n        return NULL;\r\n \r\n    Node* zHead = newNode(0);\r\n    diff--;\r\n    Node* temp = zHead;\r\n    while (diff--) {\r\n        temp->next = newNode(0);\r\n        temp = temp->next;\r\n    }\r\n    temp->next = sNode;\r\n    return zHead;\r\n}\r\n \r\n\/* Using this helper function we will substract the two given linked lists and will retur their difference in form of a linked list *\/\r\nNode* SubtractHelper(Node* l1, Node* l2, bool& borrow)\r\n{\r\n    if (l1 == NULL && l2 == NULL && borrow == 0)\r\n        return NULL;\r\n \r\n    Node* previous\r\n        = SubtractHelper(\r\n            l1 ? l1->next : NULL,\r\n            l2 ? l2->next : NULL, borrow);\r\n \r\n    int d1 = l1->data;\r\n    int d2 = l2->data;\r\n    int sub = 0;\r\n \r\n    if (borrow) {\r\n        d1--;\r\n        borrow = false;\r\n    }\r\n \r\n    if (d1 < d2) {\r\n        borrow = true;\r\n        d1 = d1 + 10;\r\n    }\r\n \r\n    sub = d1 - d2;\r\n \r\n    Node* current = newNode(sub);\r\n \r\n    current->next = previous;\r\n \r\n    return current;\r\n}\r\n \r\n\/* Main function for substraction of linked lists *\/\r\nNode* subtractLinkedList(Node* l1, Node* l2)\r\n{\r\n    if (l1 == NULL && l2 == NULL)\r\n        return NULL;\r\n    \r\n    int lenLst1 = findLength(l1);\r\n    int lenLst2 = findLength(l2);\r\n \r\n    Node *largerListNode = NULL, *smallerListNode = NULL;\r\n \r\n    Node* temp1 = l1;\r\n    Node* temp2 = l2;\r\n\r\n    if (lenLst1 != lenLst2) {\r\n        largerListNode = lenLst1 > lenLst2 ? l1 : l2;\r\n        smallerListNode = lenLst1 > lenLst2 ? l2 : l1;\r\n        smallerListNode = paddZeros(smallerListNode, abs(lenLst1 - lenLst2));\r\n    }\r\n \r\n    else {\r\n        while (l1 && l2) {\r\n            if (l1->data != l2->data) {\r\n                largerListNode = l1->data > l2->data ? temp1 : temp2;\r\n                smallerListNode = l1->data > l2->data ? temp2 : temp1;\r\n                break;\r\n            }\r\n            l1 = l1->next;\r\n            l2 = l2->next;\r\n        }\r\n    }\r\n \r\n    \r\n    bool borrow = false;\r\n    return SubtractHelper(largerListNode, smallerListNode, borrow);\r\n}\r\n \r\n\/* Using this function we will be printing the content of the linked list *\/\r\nvoid printList(struct Node* Node)\r\n{\r\n    while (Node != NULL) {\r\n        printf(\"%d \", Node->data);\r\n        Node = Node->next;\r\n    }\r\n    printf(\"&#92;n\");\r\n}\r\n \r\n\r\nint main()\r\n{\r\n    Node* L1 = newNode(1);\r\n    L1->next = newNode(3);\r\n    L1->next->next = newNode(5);\r\n    L1->next->next->next = newNode(7);\r\n    cout<<\"Linked list 1: \"<<endl;\r\n    printList(L1);\r\n\r\n    Node* L2 = newNode(3);\r\n    L2->next = newNode(5);\r\n    L2->next->next = newNode(8);\r\n    cout<<\"Linked list 2: \"<<endl;\r\n    printList(L2);\r\n\r\n    Node* result = subtractLinkedList(L1, L2);\r\n \r\n    cout<<\"Linked list representation of difference between L1 and L2: \"<<endl;\r\n    printList(result);\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_5238_2\">\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 Substract \r\n{\r\n\tstatic Node head; \r\n\tboolean borrow;\r\n\tstatic class Node \r\n    {\r\n\t\tint data;\r\n\t\tNode next;\r\n\t\tNode(int d)\r\n\t\t{\r\n\t\t\tdata = d;\r\n\t\t\tnext = null;\r\n\t\t}\r\n\t}\r\n\t\/* A utility function to get length of linked list *\/\r\n\tint getLength(Node node)\r\n\t{\r\n\t\tint size = 0;\r\n\t\twhile (node != null) {\r\n\t\t\tnode = node.next;\r\n\t\t\tsize++;\r\n\t\t}\r\n\t\treturn size;\r\n\t}\r\n\t\/* A Utility that padds zeros in front\r\n\tof the Node, with the given diff *\/\r\n\tNode paddZeros(Node sNode, int diff)\r\n\t{\r\n\t\tif (sNode == null)\r\n\t\t\treturn null;\r\n\r\n\t\tNode zHead = new Node(0);\r\n\t\tdiff--;\r\n\t\tNode temp = zHead;\r\n\t\twhile ((diff--) != 0) {\r\n\t\t\ttemp.next = new Node(0);\r\n\t\t\ttemp = temp.next;\r\n\t\t}\r\n\t\ttemp.next = sNode;\r\n\t\treturn zHead;\r\n\t}\r\n\t\/* Subtract LinkedList Helper is a recursive\r\n\tfunction, move till the last Node, and\r\n\tsubtract the digits and create the Node and\r\n\treturn the Node. If d1 &lt; d2, we borrow the\r\n\tnumber from previous digit. *\/\r\n\tNode subtractLinkedListHelper(Node l1, Node l2)\r\n\t{\r\n\t\tif (l1 == null &amp;&amp; l2 == null &amp;&amp; borrow == false)\r\n\t\t\treturn null;\r\n\r\n\t\tNode previous\r\n\t\t\t= subtractLinkedListHelper(\r\n\t\t\t\t(l1 != null) ? l1.next\r\n\t\t\t\t\t\t\t: null,\r\n\t\t\t\t(l2 != null) ? l2.next : null);\r\n\r\n\t\tint d1 = l1.data;\r\n\t\tint d2 = l2.data;\r\n\t\tint sub = 0;\r\n\r\n\t\t\/* if you have given the value to\r\n\t\tnext digit then reduce the d1 by 1 *\/\r\n\t\tif (borrow) {\r\n\t\t\td1--;\r\n\t\t\tborrow = false;\r\n\t\t}\r\n\r\n\t\t\/* If d1 &lt; d2, then borrow the number from\r\n\t\tprevious digit. Add 10 to d1 and set\r\n\t\tborrow = true; *\/\r\n\t\tif (d1 &lt; d2) {\r\n\t\t\tborrow = true;\r\n\t\t\td1 = d1 + 10;\r\n\t\t}\r\n\r\n\t\t\/* subtract the digits *\/\r\n\t\tsub = d1 - d2;\r\n\r\n\t\t\/* Create a Node with sub value *\/\r\n\t\tNode current = new Node(sub);\r\n\r\n\t\t\/* Set the Next pointer as Previous *\/\r\n\t\tcurrent.next = previous;\r\n\r\n\t\treturn current;\r\n\t}\r\n\t\/* This API subtracts two linked lists and\r\n\treturns the linked list which shall have the\r\n\tsubtracted result. *\/\r\n\tNode subtractLinkedList(Node l1, Node l2)\r\n\t{\r\n\t\t\/\/ Base Case.\r\n\t\tif (l1 == null &amp;&amp; l2 == null)\r\n\t\t\treturn null;\r\n\r\n\t\t\/\/ In either of the case, get the lengths\r\n\t\t\/\/ of both Linked list.\r\n\t\tint len1 = getLength(l1);\r\n\t\tint len2 = getLength(l2);\r\n\r\n\t\tNode lNode = null, sNode = null;\r\n\r\n\t\tNode temp1 = l1;\r\n\t\tNode temp2 = l2;\r\n\r\n\t\t\/\/ If lengths differ, calculate the smaller\r\n\t\t\/\/ Node and padd zeros for smaller Node and\r\n\t\t\/\/ ensure both larger Node and smaller Node\r\n\t\t\/\/ has equal length.\r\n\t\tif (len1 != len2) {\r\n\t\t\tlNode = len1 &gt; len2 ? l1 : l2;\r\n\t\t\tsNode = len1 &gt; len2 ? l2 : l1;\r\n\t\t\tsNode = paddZeros(sNode, Math.abs(len1 - len2));\r\n\t\t}\r\n\r\n\t\telse {\r\n\t\t\t\/\/ If both list lengths are equal, then\r\n\t\t\t\/\/ calculate the larger and smaller list.\r\n\t\t\t\/\/ If 5-6-7 &amp; 5-6-8 are linked list, then\r\n\t\t\t\/\/ walk through linked list at last Node\r\n\t\t\t\/\/ as 7 &lt; 8, larger Node is 5-6-8 and\r\n\t\t\t\/\/ smaller Node is 5-6-7.\r\n\t\t\twhile (l1 != null &amp;&amp; l2 != null) {\r\n\t\t\t\tif (l1.data != l2.data) {\r\n\t\t\t\t\tlNode = l1.data &gt; l2.data ? temp1 : temp2;\r\n\t\t\t\t\tsNode = l1.data &gt; l2.data ? temp2 : temp1;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tl1 = l1.next;\r\n\t\t\t\tl2 = l2.next;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\/\/ After calculating larger and smaller Node,\r\n\t\t\/\/ call subtractLinkedListHelper which returns\r\n\t\t\/\/ the subtracted linked list.\r\n\t\tborrow = false;\r\n\t\treturn subtractLinkedListHelper(lNode, sNode);\r\n\t}\r\n\tstatic void printList(Node head)\r\n\t{\r\n\t\tNode temp = head;\r\n\t\twhile (temp != null) {\r\n\t\t\tSystem.out.print(temp.data + &quot; &quot;);\r\n\t\t\ttemp = temp.next;\r\n\t\t}\r\n\t}\r\n\t\/\/ Driver program to test above\r\n\tpublic static void main(String[] args)\r\n\t{\r\n\t\tNode head = new Node(1);\r\n\t\thead.next = new Node(0);\r\n\t\thead.next.next = new Node(0);\r\n\r\n\t\tNode head2 = new Node(1);\r\n\r\n\t\tSubstract ob = new Substract();\r\n\t\tNode result = ob.subtractLinkedList(head, head2);\r\n\r\n\t\tprintList(result);\r\n\t}\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\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_5238 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_5238 a\"),jQuery(\"#tab-content_5238\"));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<p><strong>Output<\/strong><\/p>\n<p>Linked list 1:<br \/>\n1 3 5 7<br \/>\nLinked list 2:<br \/>\n3 5 8<br \/>\nLinked list representation of difference between L1 and L2:<br \/>\n0 9 9 9 <\/p>\n<p><strong>Time Complexity of subtract two linked lists:<\/strong> O(n), as no nested traversal is needed.<\/p>\n<p>So, in this article, we have tried to explain the most efficient approach to subtract two numbers represented as Linked Lists. In this, we discussed the problem statement and ways to solve the problem also we discussed the approach, its algorithm, Dry run, implementation, and complexities.<\/p>\n<h2>FAQs<\/h2>\n<ol>\n<li><strong>How do subtract two linked lists?<\/strong><\/li>\n<p>If the given linked list&#8217;s size is the same then:<\/p>\n<ul>\n<li>Find the linked list with smaller values.<\/li>\n<li>Subtract the nodes one by one of the smaller list from the larger list.<\/li>\n<li>Also, keep track of the borrow while subtracting the values.<\/li>\n<\/ul>\n<li><strong>Find the sum of the two linked lists?<\/strong><\/li>\n<ul>\n<li>Traverse the linked list and calculate the size of the linked list.<\/li>\n<li>Calculate the sum of the rightmost nodes of the linked list.<\/li>\n<li>Also, keep track of the carry while adding the value of the linked lists.<\/li>\n<\/ul>\n<li><strong>What is a linked list?<\/strong><\/li>\n<p>The linked list is a set of nodes in which each node has a pointer to the next node.<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>We already have an idea as we have solved many operations that can be performed on the linked list. In this article, we will subtract two numbers represented as linked lists. We have given two lists and we have to subtract two numbers represented as linked lists. How to Subtract Two Numbers as Linked Lists [&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-5237","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>Subtract Two Numbers Represented as Linked Lists<\/title>\n<meta name=\"description\" content=\"Learn the most efficient way to subtract two numbers represented as Linked Lists. Also learn the code implementation for this.\" \/>\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\/subtract-two-numbers-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=\"Subtract Two Numbers Represented as Linked Lists\" \/>\n<meta property=\"og:description\" content=\"Learn the most efficient way to subtract two numbers represented as Linked Lists. Also learn the code implementation for this.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-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-09-29T11:15:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-08T12:15:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.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\/subtract-two-numbers-represented-as-linked-lists\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/\"},\"author\":{\"name\":\"PrepBytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\"},\"headline\":\"Subtract Two Numbers Represented as Linked Lists\",\"datePublished\":\"2021-09-29T11:15:32+00:00\",\"dateModified\":\"2022-11-08T12:15:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/\"},\"wordCount\":862,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/\",\"name\":\"Subtract Two Numbers Represented as Linked Lists\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png\",\"datePublished\":\"2021-09-29T11:15:32+00:00\",\"dateModified\":\"2022-11-08T12:15:17+00:00\",\"description\":\"Learn the most efficient way to subtract two numbers represented as Linked Lists. Also learn the code implementation for this.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-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\":\"Subtract Two Numbers 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":"Subtract Two Numbers Represented as Linked Lists","description":"Learn the most efficient way to subtract two numbers represented as Linked Lists. Also learn the code implementation for this.","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\/subtract-two-numbers-represented-as-linked-lists\/","og_locale":"en_US","og_type":"article","og_title":"Subtract Two Numbers Represented as Linked Lists","og_description":"Learn the most efficient way to subtract two numbers represented as Linked Lists. Also learn the code implementation for this.","og_url":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-09-29T11:15:32+00:00","article_modified_time":"2022-11-08T12:15:17+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.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\/subtract-two-numbers-represented-as-linked-lists\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/"},"author":{"name":"PrepBytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e"},"headline":"Subtract Two Numbers Represented as Linked Lists","datePublished":"2021-09-29T11:15:32+00:00","dateModified":"2022-11-08T12:15:17+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/"},"wordCount":862,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/","url":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/","name":"Subtract Two Numbers Represented as Linked Lists","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png","datePublished":"2021-09-29T11:15:32+00:00","dateModified":"2022-11-08T12:15:17+00:00","description":"Learn the most efficient way to subtract two numbers represented as Linked Lists. Also learn the code implementation for this.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-represented-as-linked-lists\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645007619229-Article_165.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/subtract-two-numbers-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":"Subtract Two Numbers 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\/5237","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=5237"}],"version-history":[{"count":9,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5237\/revisions"}],"predecessor-version":[{"id":10382,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5237\/revisions\/10382"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=5237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=5237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=5237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}