{"id":5834,"date":"2021-10-25T10:46:45","date_gmt":"2021-10-25T10:46:45","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=5834"},"modified":"2022-11-28T11:42:39","modified_gmt":"2022-11-28T11:42:39","slug":"make-loop-at-k-th-position-in-the-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/","title":{"rendered":"Make loop at K-Th position in the Linked List"},"content":{"rendered":"<p>In this article, we will see a new coding problem of the linked list i.e.\u201d Create a loop in linked list\u201d A linked list is a linear data structure. Each Node contains a data field and a pointer to the next Node. In Linked List, unlike arrays, elements are not stored at contiguous memory locations but rather at different memory locations. Linked Lists are one of the most fundamental and important data structures having a wide range of applications. Linked Lists are also important from the perspective of interviews as well. Let us understand the problem statement of how to create a loop in linked list.<\/p>\n<h2>How to create a loop in linked list<\/h2>\n<p>We will be given a linked list and an integer <strong>K<\/strong>. We need to attach the last node of the list to the K^{th} node from starting of the list.<\/p>\n<p>To understand this problem statement, let us take an example.<\/p>\n<p>If the given linked list is 3\u21921\u21928\u21922\u21924\u2192NULL and <strong>K = 3<\/strong>, then according to the problem statement:<\/p>\n<ul>\n<li>In the given linked list the third node of the list is <strong>8<\/strong>.<\/li>\n<li>So, we need to attach the tail of the list, i.e., <strong>4<\/strong> with <strong>8<\/strong>.<\/li>\n<li>So, after connecting <strong>4<\/strong> to <strong>8<\/strong>, the list will look like this:<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg\" alt=\"\" \/><\/p>\n<p>At this point, we have understood the problem statement. Now we will try to formulate an approach for this problem.<\/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 of how to create a loop in linked list<\/h2>\n<ol>\n<li>Firstly, we need to reach the K^{th} node of the list.<\/li>\n<li>After we reach the K^{th} node, we need to save this node\u2019s address in a pointer variable.<\/li>\n<li>Then, we need to reach the end of the list and connect it with the K^{th} node (using the pointer variable which we used to store the address of K^{th} node in step 2).<\/li>\n<\/ol>\n<h2>Algorithm of how to create a loop in linked list<\/h2>\n<ol>\n<li>Initialize a <strong>count<\/strong> variable with <strong>1<\/strong> and a variable <strong>temp<\/strong> with the first node of the list.<\/li>\n<li>\n<p>Run a while loop till the <strong>count<\/strong> is less than <strong>K<\/strong>.<\/p>\n<ul>\n<li>Inside the while loop, in each iteration, increment <strong>count<\/strong> by one and move <strong>temp<\/strong> by one node.<\/li>\n<\/ul>\n<\/li>\n<li>Save the <strong>temp<\/strong> in the <strong>kth_node<\/strong> variable.<\/li>\n<li>Run a while loop till <strong>temp<\/strong> is not NULL.\n<ul>\n<li>Inside the while loop, advance <strong>temp<\/strong> by one node in each iteration.<\/li>\n<\/ul>\n<\/li>\n<li>At last, connect <strong>temp<\/strong> with <strong>kth_node<\/strong> i.e., <strong>temp-&gt;next = kth_node<\/strong>.<\/li>\n<\/ol>\n<h3>Dry Run of how to create a loop in linked list<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_1-1-1.jpg\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_2-4.jpg\" alt=\"\" \/><\/p>\n<h2>Code Implementation of how to create a loop in linked list<\/h2>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5835 {\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_5835 .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_5835 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5835 .wpsm_nav-tabs > li.active > a, #tab_container_5835 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5835 .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_5835 .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_5835 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5835 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5835 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5835 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5835 .wpsm_nav-tabs > li > a:hover , #tab_container_5835 .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_5835 .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_5835 .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_5835 .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_5835 .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_5835 .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_5835 .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_5835 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5835 .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_5835 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5835 .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_5835 .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_5835\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5835\">\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_5835_1\" aria-controls=\"tabs_desc_5835_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_5835_2\" aria-controls=\"tabs_desc_5835_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_5835_3\" aria-controls=\"tabs_desc_5835_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_5835_4\" aria-controls=\"tabs_desc_5835_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_5835\">\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_5835_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&lt;stdio.h&gt;\r\n#include&lt;stdlib.h&gt;\r\n\r\nstruct Node {\r\n    int data;\r\n    struct Node* next;\r\n};\r\n \r\n\/* Function to make loop at k-th elements of\r\nlinked list *\/\r\nstruct Node* newNode(int x)\r\n{\r\n    struct Node* node = malloc(sizeof(struct Node*));\r\n    node-&gt;data = x;\r\n    node-&gt;next = NULL;\r\n    return node;\r\n}\r\nvoid printList(struct Node* head, int total_nodes)\r\n{\r\n    struct Node* curr = head;\r\n    int count = 0;\r\n    while (count &lt; total_nodes) {\r\n        count++;\r\n        printf(&quot;%d &quot;,curr-&gt;data);\r\n        curr = curr-&gt;next;\r\n    }\r\n}\r\n\/\/ this function will create a loop between\r\n\/\/ the last node and the Kth node\r\nvoid makeloop(struct Node** head_ref, int k)\r\n{\r\n    \/\/initialize 'temp' with the first node\r\n    struct Node* temp = *head_ref;\r\n    int count = 1;\r\n    \/\/run a while loop till 'count' is\r\n    \/\/less than 'k'\r\n    while (count &lt; k) {\r\n        temp = temp-&gt;next;\r\n        count++;\r\n    }\r\n \r\n    \/\/save the Kth node in a variable\r\n    struct Node* kth_node = temp;\r\n \r\n    \/\/traverse the list till we reach\r\n    \/\/the tail node \r\n    while (temp-&gt;next != NULL)\r\n        temp = temp-&gt;next;\r\n \r\n    \/\/join the last node with the Kth node\r\n    temp-&gt;next = kth_node;\r\n}\r\nint main(void){\r\n    struct Node* head = NULL;\r\n    head = newNode(3);\r\n    head-&gt;next = newNode(1);\r\n    head-&gt;next-&gt;next = newNode(8);\r\n    head-&gt;next-&gt;next-&gt;next = newNode(2);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next = newNode(4);\r\n    int k = 3;\r\n    printf( &quot;&#92;nGiven list&#92;n&quot;);\r\n    printList(head, 5);\r\n \r\n    makeloop(&amp;head, k);\r\n \r\n    printf(&quot;&#92;nModified list&#92;n&quot;);\r\n    printList(head, 6);\r\n    return 0;\r\n}\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_5835_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=&quot;&quot;&gt;\r\nusing namespace std;\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\nvoid printList(Node* head, int total_nodes)\r\n{\r\n    Node* curr = head;\r\n    int count = 0;\r\n    while (count &lt; total_nodes) {\r\n        count++;\r\n        cout &lt;&lt; curr-&gt;data &lt;&lt; &quot; &quot;;\r\n        curr = curr-&gt;next;\r\n    }\r\n}\r\n\r\n\/\/ this function will create a loop between\r\n\/\/ the last node and the Kth node\r\nvoid makeloop(Node** head_ref, int k)\r\n{\r\n    \/\/initialize 'temp' with the first node\r\n    Node* temp = *head_ref;\r\n    int count = 1;\r\n\r\n    \/\/run a while loop till 'count' is\r\n    \/\/less than 'k'\r\n    while (count &lt; k) {\r\n        temp = temp-&gt;next;\r\n        count++;\r\n    }\r\n \r\n    \/\/save the Kth node in a variable\r\n    Node* kth_node = temp;\r\n \r\n    \/\/traverse the list till we reach\r\n    \/\/the tail node \r\n    while (temp-&gt;next != NULL)\r\n        temp = temp-&gt;next;\r\n \r\n    \/\/join the last node with the Kth node\r\n    temp-&gt;next = kth_node;\r\n}\r\n\r\nint main(void){\r\n    Node* head = NULL;\r\n    head = new Node(3);\r\n    head-&gt;next = new Node(1);\r\n    head-&gt;next-&gt;next = new Node(8);\r\n    head-&gt;next-&gt;next-&gt;next = new Node(2);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next = new Node(4);\r\n    int k = 3;\r\n    cout &lt;&lt; &quot;&#92;nGiven list&#92;n&quot;;\r\n    printList(head, 5);\r\n \r\n    makeloop(&amp;head, k);\r\n \r\n    cout &lt;&lt; &quot;&#92;nModified list&#92;n&quot;;\r\n    printList(head, 6);\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_5835_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\n\r\nclass MakeLoop\r\n{\r\n\tstatic class Node\r\n    {\r\n\t    int data;\r\n\t    Node next;\r\n    }\r\n    static Node makeloop( Node head_ref, int k)\r\n    {\r\n\t    \/\/ traverse the linked list until loop point not found\r\n\t    Node temp = head_ref;\r\n\t    int count = 1;\r\n\t    while (count &lt; k)\r\n\t    {\r\n\t\t    temp = temp.next;\r\n\t\t    count++;\r\n\t    }\r\n        \/\/ backup the joint point\r\n\t    Node joint_point = temp;\r\n\r\n\t    \/\/ traverse remaining nodes\r\n\t    while (temp.next != null)\r\n\t\t    temp = temp.next;\r\n\r\n\t    \/\/ joint the last node to k-th element\r\n\t    temp.next = joint_point;\r\n\t    return head_ref;\r\n    }\r\n    \/\/ Function to push a node \/\r\n    static Node push( Node head_ref, int new_data)\r\n    {\r\n\t    Node new_node = new Node();\r\n\t    new_node.data = new_data;\r\n\t    new_node.next = (head_ref);\r\n\t    (head_ref) = new_node;\r\n\t    return head_ref;\r\n    }\r\n    \/\/ Function to print linked list \/\r\n    static void printList( Node head, int total_nodes)\r\n    {\r\n\t    Node curr = head;\r\n\t    int count = 0;\r\n\t    while (count &lt; total_nodes)\r\n\t    {\r\n\t\t    count++;\r\n\t\t    System.out.print(curr.data + &quot; &quot;);\r\n\t\t    curr = curr.next;\r\n\t    }\r\n    }\r\n    static int countNodes(Node ptr)\r\n    {\r\n    \tint count = 0;\r\n\t    while (ptr != null)\r\n\t    {\r\n\t\t    ptr = ptr.next;\r\n\t\t    count++;\r\n\t    }\r\n\t    return count;\r\n    }\r\n    \/\/ Driver code\r\n    public static void main(String args[])\r\n    {   \r\n\t    Node head = null;\r\n\t    head = push(head, 7);\r\n\t    head = push(head, 6);\r\n\t    head = push(head, 5);\r\n\t    head = push(head, 4);\r\n\t    head = push(head, 3);\r\n\t    head = push(head, 2);\r\n\t    head = push(head, 1);\r\n\r\n\t    int k = 4;\r\n\t    int total_nodes = countNodes(head);\r\n\r\n\t    System.out.print(&quot;&#92;nGiven list&#92;n&quot;);\r\n\t    printList(head, total_nodes);\r\n\r\n\t    head = makeloop(head, k);\r\n\r\n\t    System.out.print( &quot;&#92;nModified list&#92;n&quot;);\r\n\t    printList(head, total_nodes);\r\n    }\r\n}\r\n\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_5835_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\tdef __init__(self, data):\r\n\t\tself.data = data\r\n\t\tself.next = None\r\n\r\n# Function to make loop at k-th elements of\r\n#linked list\r\ndef makeloop(head_ref, k):\r\n\t\r\n\ttemp = head_ref\r\n\tcount = 1\r\n\twhile (count &lt; k):\r\n\t\ttemp = temp.next\r\n\t\tcount = count + 1\r\n\r\n\tjoint_point = temp\r\n\r\n\twhile (temp.next != None):\r\n\t\ttemp = temp.next\r\n\r\n\ttemp.next = joint_point\r\n\treturn head_ref\r\n\r\ndef push(head_ref, new_data):\r\n\tnew_node = Node(new_data)\r\n\tnew_node.data = new_data\r\n\tnew_node.next = head_ref\r\n\thead_ref = new_node\r\n\treturn head_ref\r\n\r\ndef printList( head, total_nodes):\r\n\tcurr = head\r\n\tcount = 0\r\n\twhile (count &lt; total_nodes):\r\n\t\tcount = count + 1\r\n\t\tprint(curr.data, end = &quot; &quot;)\r\n\t\tcurr = curr.next\r\n\t\r\nif __name__=='__main__':\r\n\t\r\n\thead = None\r\n\thead = push(head, 4)\r\n\thead = push(head, 2)\r\n\thead = push(head, 8)\r\n\thead = push(head, 1)\r\n\thead = push(head, 3)\r\n\r\n\tk = 3\r\n\r\n\tprint(&quot;Given list&quot;)\r\n\tprintList(head, 5)\r\n\r\n\tmakeloop(head, k)\r\n\r\n\tprint(&quot;&#92;nModified list&quot;)\r\n\tprintList(head, 6)\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_5835 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_5835 a\"),jQuery(\"#tab-content_5835\"));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\nGiven list\n3 1 8 2 4\nModified list\n3 1 8 2 4 8<\/code><\/pre>\n<p><strong>Time Complexity of how to create a loop in linked list:<\/strong> O(n), n is the total number of nodes in the list.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>So, in this blog, we have tried to explain how to create a loop in linked list most efficiently with a great explanation and implementation. If you want to solve more questions on Linked List, which is curated by our expert mentors at PrepBytes, you can follow this link <a href=\"https:\/\/mycode.prepbytes.com\/interview-coding\/practice\/linked-list\">Linked List<\/a>.<\/p>\n<h2>FAQs related to how to create a loop in linked list<\/h2>\n<p><strong>1. What is a linked list?<\/strong><br \/>\nA linked list is a dynamic data structure in which each element (called a node) consists of two components: data and a reference (or pointer) to the next node. A linked list is a collection of nodes, each of which is linked to the next node by a pointer.<\/p>\n<p><strong>2. Does the linked list have a loop?<\/strong><br \/>\nA loop in a linked list is a condition that occurs when there is no end to the linked list. When a loop exists in a linked list, the last pointer does not point to the Null as in a singly or doubly linked list or the head of the linked list as in a circular linked list.<\/p>\n<p><strong>3. What are the types of linked lists?<\/strong><br \/>\nTypes of Linked Lists are:<\/p>\n<ul>\n<li>Singly Linked list.<\/li>\n<li>Doubly Linked list.<\/li>\n<li>Circular Linked list.<\/li>\n<li>Doubly Circular Linked list.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will see a new coding problem of the linked list i.e.\u201d Create a loop in linked list\u201d A linked list is a linear data structure. Each Node contains a data field and a pointer to the next Node. In Linked List, unlike arrays, elements are not stored at contiguous memory locations [&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-5834","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>Make loop at K-Th position in the Linked List | Linked list articles | PrepBytes Blog<\/title>\n<meta name=\"description\" content=\"Learn how to make a loop at the K^{th} position in a 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\/make-loop-at-k-th-position-in-the-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Make loop at K-Th position in the Linked List | Linked list articles | PrepBytes Blog\" \/>\n<meta property=\"og:description\" content=\"Learn how to make a loop at the K^{th} position in a linked list.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-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-10-25T10:46:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-28T11:42:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg\" \/>\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\/make-loop-at-k-th-position-in-the-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Make loop at K-Th position in the Linked List\",\"datePublished\":\"2021-10-25T10:46:45+00:00\",\"dateModified\":\"2022-11-28T11:42:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/\"},\"wordCount\":704,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/\",\"name\":\"Make loop at K-Th position in the Linked List | Linked list articles | PrepBytes Blog\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg\",\"datePublished\":\"2021-10-25T10:46:45+00:00\",\"dateModified\":\"2022-11-28T11:42:39+00:00\",\"description\":\"Learn how to make a loop at the K^{th} position in a linked list.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg\",\"contentUrl\":\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg\",\"width\":600,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-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\":\"Make loop at K-Th position in the 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":"Make loop at K-Th position in the Linked List | Linked list articles | PrepBytes Blog","description":"Learn how to make a loop at the K^{th} position in a 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\/make-loop-at-k-th-position-in-the-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Make loop at K-Th position in the Linked List | Linked list articles | PrepBytes Blog","og_description":"Learn how to make a loop at the K^{th} position in a linked list.","og_url":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-10-25T10:46:45+00:00","article_modified_time":"2022-11-28T11:42:39+00:00","og_image":[{"url":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg","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\/make-loop-at-k-th-position-in-the-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Make loop at K-Th position in the Linked List","datePublished":"2021-10-25T10:46:45+00:00","dateModified":"2022-11-28T11:42:39+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/"},"wordCount":704,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/","name":"Make loop at K-Th position in the Linked List | Linked list articles | PrepBytes Blog","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg","datePublished":"2021-10-25T10:46:45+00:00","dateModified":"2022-11-28T11:42:39+00:00","description":"Learn how to make a loop at the K^{th} position in a linked list.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-linked-list\/#primaryimage","url":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg","contentUrl":"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_3-2.jpg","width":600,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/make-loop-at-k-th-position-in-the-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":"Make loop at K-Th position in the 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\/5834","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=5834"}],"version-history":[{"count":5,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5834\/revisions"}],"predecessor-version":[{"id":10797,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5834\/revisions\/10797"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=5834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=5834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=5834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}