{"id":5039,"date":"2021-09-18T11:06:05","date_gmt":"2021-09-18T11:06:05","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=5039"},"modified":"2023-11-27T05:01:46","modified_gmt":"2023-11-27T05:01:46","slug":"reverse-a-sublist-of-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/","title":{"rendered":"Reverse A Sublist Of Linked List"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png\" alt=\"\" \/><br \/>\nManipulating linked lists is a core skill for programmers working with data structures. Among the numerous operations, reversing a sublist within a linked list presents an intriguing challenge. This article delves into the intricacies of reversing a sublist in a linked list data structure. Understanding this operation not only showcases a grasp of linked list manipulation but also demonstrates proficiency in algorithmic thinking and problem-solving. Given a linked list and two integers (say \u2018m\u2019 and \u2018n\u2019). We need to reverse the list from position m to n and leave the rest of the list as it is.<\/p>\n<h2>How To Reverse a Sublist of Linked List?<\/h2>\n<p>Let\u2019s try to understand this problem with the help of examples.<\/p>\n<p>If the list given to us is:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/input-13.png\" alt=\"\" \/><\/p>\n<ul>\n<li>According to the problem statement, we need to reverse the given list from position m=3 to position n=5, i.e., from 3<sup>rd<\/sup> node to 5<sup>th<\/sup> node (both inclusive). <\/li>\n<li>The sublist from position 3 to position 5 is 1\u21927\u21924, so we need to reverse this sublist of the given linked list.<\/li>\n<li>Our final output linked list after reversing the sublist is: <\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/output-11.png\" alt=\"\" \/><\/p>\n<p>Let\u2019s take another example, let the input be 9\u21924\u21928\u21927\u21921\u2192NULL, m = 2, n = 3.<\/p>\n<ul>\n<li>So in this case, after reversing the sublist from position 2 to 3 (both inclusive), our final output list will be 9\u21928\u21924\u21927\u21921\u2192NULL.<\/li>\n<\/ul>\n<h5>Some more examples<\/h5>\n<p>Sample Input 1: 1\u21923\u21925\u21927\u21929\u219211\u219213\u2192NULL, m = 2, n = 4<br \/>\nSample Output 1: 1\u21927\u21925\u21923\u21929\u219211\u219213\u2192NULL<\/p>\n<p>Sample Output 2: 1\u21922\u21925\u21926\u21924\u21928\u2192NULL, m = 2, n = 6<br \/>\nSample Output 2: 1\u21928\u21924\u21926\u21925\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.<br \/>\nIf stuck, no problem, we will thoroughly see how we can approach this problem in the next section.<\/p>\n<p>Let\u2019s move to the approach section.<\/p>\n<h3>Approach<\/h3>\n<p>Our approach will be quite straightforward.<\/p>\n<ul>\n<li>At first, we need to find the m<sup>th<\/sup> node.<\/li>\n<li>Then we find the n<sup>th<\/sup> node.<\/li>\n<li>After that, we need to detach the list that is present after the n<sup>th<\/sup> node and save the (n+1)<sup>th<\/sup> node\u2019s address in a variable.<\/li>\n<li>Then we need to reverse the sublist starting from the m<sup>th<\/sup> node to the n<sup>th node.<\/li>\n<li>Now, we need to attach this reversed list after (m-1)<sup>th<\/sup> node and also attach the remaining list whose address we stored in a temporary variable after the n<sup>th<\/sup> node.<\/li>\n<\/ul>\n<p>Following these steps will give us the required answer.<\/p>\n<h3>Algorithm<\/h3>\n<ul>\n<li>Initialize four pointers named <strong>StartRev<\/strong>, <strong>BeforeRev<\/strong>, <strong>EndRev<\/strong>, <strong>AfterRev<\/strong> with NULL and an integer variable <strong>i<\/strong> with 1.<\/li>\n<li>Initialize a <strong>curr<\/strong> variable with the head pointer for iteration of the list.<\/li>\n<li>Now, run a while loop till <strong>curr<\/strong> reaches NULL, and <strong>i<\/strong> is less than <strong>n<\/strong>.<\/li>\n<li>Inside the while loop:\n<ul>\n<li>If <strong>i<\/strong> is less than <strong>m<\/strong>, update <strong>BeforeRev<\/strong> with <strong>curr<\/strong>.<\/li>\n<li>If <strong>i<\/strong> is equal to <strong>m<\/strong>, update <strong>StartRev<\/strong> with <strong>curr<\/strong>.<\/li>\n<li>If <strong>i<\/strong> is equal to <strong>n<\/strong>, update <strong>EndRev<\/strong> with <strong>curr<\/strong> and <strong>AfterRev<\/strong> with <strong>curr-&gt;next<\/strong>.<\/li>\n<li>Increment <strong>i<\/strong> by 1.<\/li>\n<\/ul>\n<\/li>\n<li>Make <strong>EndRev-&gt;next<\/strong> as NULL to detach the list after the m<sup>th<\/sup> node.<\/li>\n<li>Now, reverse the list with <strong>StartRev<\/strong> as starting node.<\/li>\n<li>Check if <strong>BeforeRev<\/strong> is NULL or not:\n<ul>\n<li>If it is not NULL, then assign <strong>BeforeRev-&gt;next<\/strong> to <strong>EndRev<\/strong>.<\/li>\n<li>Else update <strong>head<\/strong> with <strong>EndRev<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li>Assign <strong>StartRev-&gt;next<\/strong> with <strong>AfterRev<\/strong>.<\/li>\n<li>Return the head pointer.<\/li>\n<\/ul>\n<p>If you are not aware of how to reverse a linked list, please check this article <a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-reverse-a-linked-list\/\">Reversing a linked list<\/a>.<\/p>\n<h3>Dry Run<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_1-7.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_2-7.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/09\/p_3-3.png\" alt=\"\" \/><\/p>\n<h3>Code Implementation:<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5040 {\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_5040 .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_5040 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5040 .wpsm_nav-tabs > li.active > a, #tab_container_5040 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5040 .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_5040 .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_5040 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5040 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5040 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5040 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5040 .wpsm_nav-tabs > li > a:hover , #tab_container_5040 .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_5040 .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_5040 .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_5040 .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_5040 .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_5040 .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_5040 .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_5040 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5040 .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_5040 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5040 .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_5040 .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_5040\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5040\">\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_5040_1\" aria-controls=\"tabs_desc_5040_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_5040_2\" aria-controls=\"tabs_desc_5040_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_5040_3\" aria-controls=\"tabs_desc_5040_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>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_5040\">\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_5040_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\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n \r\n\/\/ Linked list node\r\nstruct Node {\r\n    int data;\r\n    struct Node* next;\r\n};\r\n \r\n\/\/ the standard reverse function used\r\n\/\/ to reverse a linked list\r\nstruct Node* reverse(struct Node* head)\r\n{\r\n    struct Node* prev = NULL;   \r\n    struct Node* curr = head;\r\n \r\n    while (curr) {\r\n        struct Node* next = curr-&gt;next;\r\n        curr-&gt;next = prev;\r\n        prev = curr;\r\n        curr = next;\r\n    }\r\n    return prev;\r\n}\r\n \r\n\/\/ function used to reverse a linked list\r\n\/\/ from position m to n which uses reverse\r\n\/\/ function\r\nstruct Node* reverseBetween(struct Node* head, int m, int n)\r\n{\r\n    if (m == n)\r\n        return head;\r\n \r\n    \/\/ revs and revend is start and end respectively\r\n    \/\/ of the portion of the linked list which\r\n    \/\/ need to be reversed. revs_prev is previous\r\n    \/\/ of starting position and revend_next is next\r\n    \/\/ of end of list to be reversed.\r\n    struct Node* revs = NULL, *revs_prev = NULL;\r\n    struct Node* revend = NULL, *revend_next = NULL;\r\n \r\n    \/\/ Find values of above pointers.\r\n    int i = 1;\r\n    struct Node* curr = head;\r\n    while (curr &amp;&amp; i &lt;= n) {\r\n        if (i &lt; m)\r\n            revs_prev = curr;\r\n \r\n        if (i == m)\r\n            revs = curr;\r\n \r\n        if (i == n) {\r\n            revend = curr;\r\n            revend_next = curr-&gt;next;\r\n        }\r\n \r\n        curr = curr-&gt;next;\r\n        i++;\r\n    }\r\n    revend-&gt;next = NULL;\r\n \r\n    \/\/ Reverse linked list starting with\r\n    \/\/ revs.\r\n    revend = reverse(revs);\r\n \r\n    \/\/ If starting position was not head\r\n    if (revs_prev)\r\n        revs_prev-&gt;next = revend;\r\n \r\n    \/\/ If starting position was head\r\n    else\r\n        head = revend;\r\n \r\n    revs-&gt;next = revend_next;\r\n    return head;\r\n}\r\n \r\nvoid print(struct Node* head)\r\n{\r\n    while (head != NULL) {\r\n        printf(&quot;%d &quot;, head-&gt;data);\r\n        head = head-&gt;next;\r\n    }\r\n    printf(&quot;&#92;n&quot;);\r\n}\r\n \r\n\/\/ function to add a new node at the\r\n\/\/ beginning of the list\r\nvoid push(struct Node** head_ref, int new_data)\r\n{\r\n    struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));\r\n    new_node-&gt;data = new_data;\r\n    new_node-&gt;next = (*head_ref);\r\n    (*head_ref) = new_node;\r\n}\r\n \r\n\/\/ Driver code\r\nint main()\r\n{\r\n    struct Node* head = NULL;\r\n    push(&amp;head, 7);\r\n    push(&amp;head, 6);\r\n    push(&amp;head, 5);\r\n    push(&amp;head, 4);\r\n    push(&amp;head, 3);\r\n    push(&amp;head, 2);\r\n    push(&amp;head, 1);\r\n    reverseBetween(head, 2, 4);\r\n    print(head);\r\n    return 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_5040_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 &lt;bits\/stdc++.h&gt;\r\nusing namespace std;\r\n\r\n\/* Node structure of a singly linked list *\/\r\nclass Node {\r\n    public:\r\n    int data;\r\n    Node* next;\r\n    Node(int x){\r\n        data = x;\r\n        next = NULL;\r\n}\r\n};\r\n\r\n\/* Using this function we will be printing the linked list *\/\r\nvoid printingList(Node* head)\r\n{\r\n    Node* curr = head;\r\n    while (curr != NULL) {\r\n        cout &lt;&lt; curr-&gt;data &lt;&lt; &quot; -&gt; &quot;;\r\n        curr = curr-&gt;next;\r\n    }\r\n    cout&lt;&lt;&quot;NULL&quot;;\r\n    cout&lt;&lt;endl;\r\n}\r\n\r\n\/* Using this function we will be reversing a linked list whose head pointer is given *\/\r\nNode* reverseList(Node* head)\r\n{\r\n    Node* prev = NULL;   \r\n    Node* curr = head;\r\n \r\n    while (curr) {\r\n        Node* next = curr-&gt;next;\r\n        curr-&gt;next = prev;\r\n        prev = curr;\r\n        curr = next;\r\n    }\r\n    return prev;\r\n}\r\n \r\n\/* Using this function we will be reversing the sublist from mth till nth position *\/\r\nNode* ReverseFromMToN(Node* head, int m, int n)\r\n{\r\n    if (m == n)\r\n        return head;\r\n\r\n    Node* StartRev = NULL, *BeforeRev = NULL;\r\n    Node* EndRev = NULL, *AfterRev = NULL;\r\n \r\n    int i = 1;\r\n    Node* curr = head;\r\n    while (curr &amp;&amp; i &lt;= n) {\r\n        if (i &lt; m)\r\n            BeforeRev = curr;\r\n \r\n        if (i == m)\r\n            StartRev = curr;\r\n \r\n        if (i == n) {\r\n            EndRev = curr;\r\n            AfterRev = curr-&gt;next;\r\n        }\r\n \r\n        curr = curr-&gt;next;\r\n        i++;\r\n    }\r\n    \r\n    EndRev-&gt;next = NULL;\r\n \r\n    EndRev = reverseList(StartRev);\r\n \r\n    if (BeforeRev)\r\n        BeforeRev-&gt;next = EndRev;\r\n\r\n    else\r\n        head = EndRev;\r\n    \r\n    StartRev-&gt;next = AfterRev;\r\n \r\n    return head;\r\n}\r\n\r\nint main()\r\n{\r\n    Node *head = new Node(2);\r\n    head-&gt;next = new Node(9);\r\n    head-&gt;next-&gt;next = new Node(1);\r\n    head-&gt;next-&gt;next-&gt;next = new Node(7);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next = new Node(4);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next = new Node(8);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next = new Node(3);\r\n    cout&lt;&lt;&quot;Original given linked list before reversing sublist:&quot;&lt;&lt;endl;\r\n    printingList(head);\r\n    head = ReverseFromMToN(head, 3, 5);\r\n    cout&lt;&lt;&quot;Linked list after reversing sublist:&quot;&lt;&lt;endl;\r\n    printingList(head);\r\n    return 0;\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_5040_3\">\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\t\r\n\tdef __init__(self, data):\r\n\t\t\r\n\t\tself.data = data\r\n\t\tself.next = None\r\n\r\ndef reverse(head):\r\n\r\n\tprev = None\r\n\tcurr = head\r\n\r\n\twhile (curr):\r\n\t\tnext = curr.next\r\n\t\tcurr.next = prev\r\n\t\tprev = curr\r\n\t\tcurr = next\r\n\t\r\n\treturn prev\r\n\r\ndef reverseBetween(head, m, n):\r\n\r\n\tif (m == n):\r\n\t\treturn head\r\n\t\t\r\n\trevs = None\r\n\trevs_prev = None\r\n\trevend = None\r\n\trevend_next = None\r\n\r\n\ti = 1\r\n\tcurr = head\r\n\t\r\n\twhile (curr and i &lt;= n):\r\n\t\tif (i &lt; m):\r\n\t\t\trevs_prev = curr\r\n\r\n\t\tif (i == m):\r\n\t\t\trevs = curr\r\n\r\n\t\tif (i == n):\r\n\t\t\trevend = curr\r\n\t\t\trevend_next = curr.next\r\n\r\n\t\tcurr = curr.next\r\n\t\ti += 1\r\n\r\n\trevend.next = None\r\n\r\n\trevend = reverse(revs)\r\n\r\n\tif (revs_prev):\r\n\t\trevs_prev.next = revend\r\n\r\n\telse:\r\n\t\thead = revend\r\n\r\n\trevs.next = revend_next\r\n\treturn head\r\n\r\ndef prints(head):\r\n\r\n\twhile (head != None):\r\n\t\tprint(head.data, end = ' ')\r\n\t\thead = head.next\r\n\t\t\r\n\tprint()\r\n\r\ndef push(head_ref, new_data):\r\n\r\n\tnew_node = Node(new_data)\r\n\tnew_node.data = new_data\r\n\tnew_node.next = (head_ref)\r\n\t(head_ref) = new_node\r\n\treturn head_ref\r\n\r\nif __name__=='__main__':\r\n\t\r\n\thead = None\r\n\thead = push(head, 3)\r\n\thead = push(head, 8)\r\n\thead = push(head, 4)\r\n\thead = push(head, 7)\r\n\thead = push(head, 1)\r\n\thead = push(head, 9)\r\n\thead = push(head, 2)\r\n\t\r\n\treverseBetween(head, 3, 5)\r\n\t\r\n\tprints(head)\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_5040 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_5040 a\"),jQuery(\"#tab-content_5040\"));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<h4>Output<\/h4>\n<p>Original given linked list before reversing sublist:<br \/>\n2 -&gt; 9 -&gt; 1 -&gt; 7 -&gt; 4 -&gt; 8 -&gt; 3 -&gt; NULL<br \/>\nLinked list after reversing sublist:<br \/>\n2 -&gt; 9 -&gt; 4 -&gt; 7 -&gt; 1 -&gt; 8 -&gt; 3 -&gt; NULL<\/p>\n<p><strong>Time Complexity:<\/strong> O(n), n is the number of nodes present in the list<br \/>\n[forminator_quiz id=&#8221;5041&#8243;]<\/p>\n<p>**Conclusion**<br \/>\nReversing a sublist within a linked list is a valuable skill that demonstrates adeptness in linked list manipulation and algorithmic problem-solving. Understanding the intricacies of identifying the sublist, manipulating pointers, and ensuring efficient traversal aids in mastering this operation. Proficiency in this fundamental operation contributes to a programmer&#8217;s ability to efficiently manage and manipulate linked list data structures, unlocking potential applications across diverse domains in computer science and software development.<\/p>\n<p>## FAQ: Reversing a Sublist of a Linked List<br \/>\nHere are some FAQs related to how to reverse a Sublist of Linked List.<\/p>\n<p>**1. What does &#8220;reversing a sublist of a linked list&#8221; mean?**<br \/>\nReversing a sublist in a linked list involves altering the order of elements within a specified range. For instance, given a linked list with nodes 1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; 5 and a sublist specified from positions 2 to 4, the resulting list after reversal would be 1 -&gt; 4 -&gt; 3 -&gt; 2 -&gt; 5.<\/p>\n<p>**2. How is a sublist reversal operation performed on a linked list?**<br \/>\nTo reverse a sublist in a linked list, the algorithm typically involves traversing the list to find the starting and ending nodes of the sublist. Then, the nodes within the sublist are reversed by changing the pointers, effectively altering their order.<\/p>\n<p>**3. What are the key challenges when reversing a sublist in a linked list?**<br \/>\nEnsuring accurate identification of the starting and ending points of the sublist is crucial. Moreover, handling cases where the sublist begins at the head or ends at the tail of the linked list requires special consideration in pointer manipulation.<\/p>\n<p>**4. Can reversing a sublist be achieved in constant space complexity?**<br \/>\nReversing a sublist usually requires linear space complexity due to the traversal and temporary storage of nodes. However, in-place reversal techniques can be employed to minimize space usage, where pointers are adjusted without extra memory allocation.<\/p>\n<p>**5. What are the applications of reversing sublists in linked lists?**<br \/>\nReversing sublists within linked lists finds applications in various algorithms and data manipulation tasks, such as in competitive programming challenges, string and list manipulations in software development, and specific tasks in database management systems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Manipulating linked lists is a core skill for programmers working with data structures. Among the numerous operations, reversing a sublist within a linked list presents an intriguing challenge. This article delves into the intricacies of reversing a sublist in a linked list data structure. Understanding this operation not only showcases a grasp of linked list [&hellip;]<\/p>\n","protected":false},"author":52,"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-5039","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>Reverse A Sublist Of Linked List | Linked list articles | PrepBytes Blog<\/title>\n<meta name=\"description\" content=\"learn to reverse a sublist of a given linked list.\" \/>\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\/reverse-a-sublist-of-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reverse A Sublist Of Linked List | Linked list articles | PrepBytes Blog\" \/>\n<meta property=\"og:description\" content=\"learn to reverse a sublist of a given linked list.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/\" \/>\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-18T11:06:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-27T05:01:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.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\/reverse-a-sublist-of-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Reverse A Sublist Of Linked List\",\"datePublished\":\"2021-09-18T11:06:05+00:00\",\"dateModified\":\"2023-11-27T05:01:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/\"},\"wordCount\":987,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/\",\"name\":\"Reverse A Sublist Of Linked List | Linked list articles | PrepBytes Blog\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png\",\"datePublished\":\"2021-09-18T11:06:05+00:00\",\"dateModified\":\"2023-11-27T05:01:46+00:00\",\"description\":\"learn to reverse a sublist of a given linked list.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#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\":\"Reverse A Sublist Of Linked List\"}]},{\"@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\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Reverse A Sublist Of Linked List | Linked list articles | PrepBytes Blog","description":"learn to reverse a sublist of a given linked list.","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\/reverse-a-sublist-of-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Reverse A Sublist Of Linked List | Linked list articles | PrepBytes Blog","og_description":"learn to reverse a sublist of a given linked list.","og_url":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-09-18T11:06:05+00:00","article_modified_time":"2023-11-27T05:01:46+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.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\/reverse-a-sublist-of-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Reverse A Sublist Of Linked List","datePublished":"2021-09-18T11:06:05+00:00","dateModified":"2023-11-27T05:01:46+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/"},"wordCount":987,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/","name":"Reverse A Sublist Of Linked List | Linked list articles | PrepBytes Blog","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png","datePublished":"2021-09-18T11:06:05+00:00","dateModified":"2023-11-27T05:01:46+00:00","description":"learn to reverse a sublist of a given linked list.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645001275404-Article_148.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/reverse-a-sublist-of-linked-list\/#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":"Reverse A Sublist Of Linked List"}]},{"@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\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5039","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\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=5039"}],"version-history":[{"count":6,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5039\/revisions"}],"predecessor-version":[{"id":18382,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5039\/revisions\/18382"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=5039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=5039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=5039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}