{"id":4455,"date":"2021-08-30T08:38:24","date_gmt":"2021-08-30T08:38:24","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=4455"},"modified":"2022-11-18T07:24:44","modified_gmt":"2022-11-18T07:24:44","slug":"move-the-first-element-to-the-end-of-the-given-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/","title":{"rendered":"Move the first element to the end of the given list"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png\" alt=\"\" \/><\/p>\n<p>This blog will describe the efficient approach to move first node to last in linked list. The linked list is one of the most important concepts and data structures to learn while preparing for interviews. Moving the first element of the linked list at the end position will help you to understand the linked list in detail. Having a good grasp of Linked Lists can be a huge plus point in a coding interview.<\/p>\n<h3>Problem Statement<\/h3>\n<p>In this problem, we are given a singly linked list. We have to move the first element of the linked list to the end of the list.<\/p>\n<h3>Problem Statement Understanding To Move First Element To Last In Linked List<\/h3>\n<p>Let\u2019s try to understand the problem statement with the help of a few examples by referring some best sites to learn coding<\/p>\n<p>Suppose the given list is 1 \u2192 7 \u2192 13 \u2192 15. <\/p>\n<ul>\n<li>According to the problem statement, we have to move the first element of the linked list to the end of the list. <\/li>\n<li>So to move the first element to the end of the list, we will have to remove the first element from its position and make it the last element. If we move the first element to the end of the list, the resultant list will look like 7 \u2192 13 \u2192 15 \u2192 1<\/li>\n<\/ul>\n<p>Now let\u2019s take another example, say if the given list is 3 \u2192 5 \u2192 8 \u2192 10.<\/p>\n<ul>\n<li>We will move the first element of the list to the end of the list such that our resultant list will look like 5 \u2192 8 \u2192 10 \u2192 3<\/li>\n<\/ul>\n<p><strong>Explanation:<\/strong> As we can see, the first element of the list is moved to the end of the list.<\/p>\n<h5>Some more examples<\/h5>\n<p><strong>Input<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-2-10.png\" alt=\"\" \/><\/p>\n<p><strong>Output<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/output2.png\" alt=\"\" \/><\/p>\n<p><strong>Input<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-16.png\" alt=\"\" \/><\/p>\n<p><strong>Output<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/output-8.png\" alt=\"\" \/><\/p>\n<p>This question is not a very complex one. Let us first think about what we will need to complete the required task. <\/p>\n<ul>\n<li>We will need a pointer to the first node and,<\/li>\n<li>Another pointer to the last node. <\/li>\n<li>Now that we know that we need these two pointers, we can easily find them with the <a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/circular-linked-list-traversal\/ \">help of list traversal.<\/a>\n<\/li>\n<\/ul>\n<p>Let us have a glance at the approach.<\/p>\n<h3>Approach and Algorithm To Move First Element To Last In Linked List<\/h3>\n<p>Our approach will be simple:<\/p>\n<ul>\n<li>Create two pointers, <strong>first<\/strong> and <strong>last<\/strong>. Both will initially point to the head. <\/li>\n<li>Now, <strong>first<\/strong> will keep pointing to the head and with the help of a while loop, we will increment the <strong>last<\/strong> pointer till it reaches the end of the list.<\/li>\n<li>Now, we will make head point to the next of <strong>first<\/strong>, as after the required task of moving the first node to the end of the list, the second node will become the new head. <\/li>\n<li>After that, we will make the next of the <strong>last<\/strong> point to <strong>first<\/strong>, as now <strong>first<\/strong> is the new last node of the list. <\/li>\n<li>In the end, we will make next of the <strong>first<\/strong> point to NULL, as it is now the last node of the list.<\/li>\n<li>Finally, after the above steps, we will have successfully moved the first element of the linked list to the end of the list.<\/li>\n<\/ul>\n<h3>Dry Run To Move First Element To Last In Linked List<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Move-the-first-element-to-the-end-of-the-given-list.png\" alt=\"\" \/><\/p>\n<h3>Code Implementation To Move First Element To Last In Linked List<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_4457 {\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_4457 .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_4457 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_4457 .wpsm_nav-tabs > li.active > a, #tab_container_4457 .wpsm_nav-tabs > li.active > a:hover, #tab_container_4457 .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_4457 .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_4457 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_4457 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_4457 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_4457 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_4457 .wpsm_nav-tabs > li > a:hover , #tab_container_4457 .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_4457 .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_4457 .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_4457 .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_4457 .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_4457 .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_4457 .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_4457 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_4457 .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_4457 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_4457 .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_4457 .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_4457\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_4457\">\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_4457_1\" aria-controls=\"tabs_desc_4457_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_4457_2\" aria-controls=\"tabs_desc_4457_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\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_4457_3\" aria-controls=\"tabs_desc_4457_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_4457\">\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_4457_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\n\/* Link list node *\/\r\nstruct Node {\r\n    int data;\r\n    struct Node* next;\r\n};\r\n \r\n\/* function prototypes *\/\r\nstruct Node* SortedMerge(struct Node* a, struct Node* b);\r\nvoid FrontBackSplit(struct Node* source,\r\n                    struct Node** frontRef, struct Node** backRef);\r\n \r\n\/* sorts the linked list by changing next pointers (not data) *\/\r\nvoid MergeSort(struct Node** headRef)\r\n{\r\n    struct Node* head = *headRef;\r\n    struct Node* a;\r\n    struct Node* b;\r\n \r\n    \/* Base case -- length 0 or 1 *\/\r\n    if ((head == NULL) || (head-&gt;next == NULL)) {\r\n        return;\r\n    }\r\n \r\n    \/* Split head into 'a' and 'b' sublists *\/\r\n    FrontBackSplit(head, &amp;a, &amp;b);\r\n \r\n    \/* Recursively sort the sublists *\/\r\n    MergeSort(&amp;a);\r\n    MergeSort(&amp;b);\r\n \r\n    \/* answer = merge the two sorted lists together *\/\r\n    *headRef = SortedMerge(a, b);\r\n}\r\n \r\n\/* See https:\/\/ www.geeksforgeeks.org\/?p=3622 for details of this\r\nfunction *\/\r\nstruct Node* SortedMerge(struct Node* a, struct Node* b)\r\n{\r\n    struct Node* result = NULL;\r\n \r\n    \/* Base cases *\/\r\n    if (a == NULL)\r\n        return (b);\r\n    else if (b == NULL)\r\n        return (a);\r\n \r\n    \/* Pick either a or b, and recur *\/\r\n    if (a-&gt;data &lt;= b-&gt;data) {\r\n        result = a;\r\n        result-&gt;next = SortedMerge(a-&gt;next, b);\r\n    }\r\n    else {\r\n        result = b;\r\n        result-&gt;next = SortedMerge(a, b-&gt;next);\r\n    }\r\n    return (result);\r\n}\r\n \r\n\/* UTILITY FUNCTIONS *\/\r\n\/* Split the nodes of the given list into front and back halves,\r\n    and return the two lists using the reference parameters.\r\n    If the length is odd, the extra node should go in the front list.\r\n    Uses the fast\/slow pointer strategy. *\/\r\nvoid FrontBackSplit(struct Node* source,\r\n                    struct Node** frontRef, struct Node** backRef)\r\n{\r\n    struct Node* fast;\r\n    struct Node* slow;\r\n    slow = source;\r\n    fast = source-&gt;next;\r\n \r\n    \/* Advance 'fast' two nodes, and advance 'slow' one node *\/\r\n    while (fast != NULL) {\r\n        fast = fast-&gt;next;\r\n        if (fast != NULL) {\r\n            slow = slow-&gt;next;\r\n            fast = fast-&gt;next;\r\n        }\r\n    }\r\n \r\n    \/* 'slow' is before the midpoint in the list, so split it in two\r\n    at that point. *\/\r\n    *frontRef = source;\r\n    *backRef = slow-&gt;next;\r\n    slow-&gt;next = NULL;\r\n}\r\n \r\n\/* Function to print nodes in a given linked list *\/\r\nvoid printList(struct Node* node)\r\n{\r\n    while (node != NULL) {\r\n        printf(&quot;%d &quot;, node-&gt;data);\r\n        node = node-&gt;next;\r\n    }\r\n}\r\n \r\n\/* Function to insert a node at the beginning of the linked list *\/\r\nvoid push(struct Node** head_ref, int new_data)\r\n{\r\n    \/* allocate node *\/\r\n    struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));\r\n \r\n    \/* put in the data *\/\r\n    new_node-&gt;data = new_data;\r\n \r\n    \/* link the old list off the new node *\/\r\n    new_node-&gt;next = (*head_ref);\r\n \r\n    \/* move the head to point to the new node *\/\r\n    (*head_ref) = new_node;\r\n}\r\n \r\n\/* Driver program to test above functions*\/\r\nint main()\r\n{\r\n    \/* Start with the empty list *\/\r\n    struct Node* res = NULL;\r\n    struct Node* a = NULL;\r\n \r\n    \/* Let us create a unsorted linked lists to test the functions\r\nCreated lists shall be a: 2-&gt;3-&gt;20-&gt;5-&gt;10-&gt;15 *\/\r\n    push(&amp;a, 15);\r\n    push(&amp;a, 10);\r\n    push(&amp;a, 5);\r\n    push(&amp;a, 20);\r\n    push(&amp;a, 3);\r\n    push(&amp;a, 2);\r\n \r\n    \/* Sort the above created Linked List *\/\r\n    MergeSort(&amp;a);\r\n \r\n    printf(&quot;Sorted Linked List is: &#92;n&quot;);\r\n    printList(a);\r\n \r\n    getchar();\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_4457_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\npublic class Sol\r\n{\r\nstatic class Node\r\n{\r\n    int data;\r\n    Node next;\r\n};\r\n\r\nstatic Node moveToEnd( Node head_ref)\r\n{\r\n\r\n    if (head_ref == null || (head_ref).next == null)\r\n        return null;\r\n\r\n    Node first = head_ref;\r\n    Node last = head_ref;\r\n\r\n    while (last.next != null)\r\n    {\r\n        last = last.next;\r\n    }\r\n\r\n    head_ref = first.next;\r\n    \r\nlast.next = first;\r\n    first.next = null;\r\n\r\n    \r\n    return head_ref;\r\n}\r\n \r\n\r\nstatic Node push( Node head_ref, int new_data)\r\n{\r\n    Node new_node = new Node();\r\n    new_node.data = new_data;\r\n    new_node.next = (head_ref);\r\n    (head_ref) = new_node;\r\n    return head_ref;\r\n}\r\n\r\nstatic void printList( Node node)\r\n{\r\n    while (node != null)\r\n    {\r\n        System.out.printf(&quot;%d &quot;, node.data);\r\n        node = node.next;\r\n    }\r\n}\r\n\r\npublic static void main(String args[])\r\n{\r\n    Node start = null;\r\n\r\n    start = push(start, 15);\r\n    start = push(start, 13);\r\n    start = push(start, 7);\r\n\r\n    start = push(start, 1);\r\n \r\n    System.out.printf(&quot;&#92;n Linked list before &#92;n&quot;);\r\n    printList(start);\r\n \r\n    start = moveToEnd(start);\r\n \r\n    System.out.printf(&quot;&#92;n Linked list after &#92;n&quot;);\r\n    printList(start);\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_4457_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    def __init__(self):\r\n        self.data = 0\r\n        self.next = None\r\n\r\ndef moveToEnd( head_ref) :\r\n\r\n    if (head_ref == None or (head_ref).next == None) :\r\n        return None\r\n\r\n    first = head_ref\r\n    last = head_ref\r\n\r\n    while (last.next != None) :\r\n    \r\n        last = last.next\r\n    \r\n    head_ref = first.next\r\n    first.next = None\r\n    last.next = first\r\n    return head_ref\r\n\r\ndef push( head_ref, new_data) :\r\n\r\n    new_node = Node()\r\n    new_node.data = new_data\r\n    new_node.next = (head_ref)\r\n    (head_ref) = new_node\r\n    return head_ref\r\n\r\ndef printList(node) :\r\n\r\n    while (node != None):\r\n    \r\n        print(node.data, end = &quot; &quot;)\r\n        node = node.next\r\n    \r\n\r\nstart = None\r\n\r\nstart = push(start, 5)\r\nstart = push(start, 4)\r\nstart = push(start, 3)\r\nstart = push(start, 2)\r\nstart = push(start, 1)\r\n\r\nprint(&quot;Linked list before moving first to end&quot;)\r\nprintList(start)\r\n\r\nstart = moveToEnd(start)\r\n\r\nprint(&quot;&#92;nLinked list after moving first to end&quot;)\r\nprintList(start)\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_4457 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_4457 a\"),jQuery(\"#tab-content_4457\"));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>Linked list before<br \/>\n1 7 13 15<br \/>\nLinked list after<br \/>\n7 13 15 1 <\/p>\n<p><strong>Space Complexity To Move First Element To Last In Linked List:<\/strong> O(1), as only temporary variables are being created<\/p>\n<p>This blog will describe the best approach To Move First Element To Last In Linked List. Linked List is a topic which is required for the technical interview. If you want to solve more questions on Linked List, which are 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<table width=\"641\">\n<tbody>\n<tr>\n<td colspan=\"2\" width=\"641\" style=\"text-align: center\"><strong>Related Articles<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/doubly-circular-linked-list-introduction-and-insertion\/\">Doubly circular linked list in data structure<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/advantages-disadvantages-and-uses-of-a-doubly-linked-list\/\">Application of doubly linked list<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/applications-of-linked-list-data-structure\/\">Applications of linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/difference-between-a-singly-linked-list-and-a-doubly-linked-list\/\">Singly linked list vs doubly linked list<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/advantage-and-disadvantage-of-linked-list-over-array\/\">Advantages and disadvantages of linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/menu-driven-program-for-all-operations-on-doubly-linked-list-in-c\/\">Doubly linked list all operations in C<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/binary-search\/binary-search-on-linked-list\/\">Binary search in linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/bubble-sort-for-linked-list-by-swapping-nodes\/\">Bubble sort linked list<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/delete-a-node-in-doubly-linked-list\/\">Deletion in doubly linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/delete-middle-of-linked-list\/\">Delete the middle node of a linked list<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/adding-two-polynomials-using-linked-list\/\">Polynomial addition using linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/find-the-smallest-and-largest-elements-in-a-singly-linked-list\/\">Find max value and min value in linked list<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/insert-a-node-at-a-specific-position-in-a-linked-list\/\">Insert a node at a specific position in a linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/swap-nodes-in-a-linked-list-without-swapping-data\/\">Swap nodes in linked list<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/add-two-numbers-represented-by-linked-lists-set-1\/\">Add two numbers represented by linked lists<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/find-the-first-node-of-the-loop-in-a-linked-list\/\">Find starting point of loop in linked list<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/merge-sort-on-a-singly-linked-list\/\">Merge sort linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/delete-a-node-at-a-given-position\/\">Delete a node from linked list at a given position<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/remove-duplicates-from-an-unsorted-linked-list\/\">Remove duplicates from unsorted linked list<\/a><\/td>\n<td width=\"321\"><a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-reverse-a-linked-list\/\">Reverse a linked list in Python<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>FAQ<\/h2>\n<p><ol>\n<strong><\/p>\n<li>Is the linked list LIFO or FIFO?<\/li>\n<p><\/strong><br \/>\nA singly-linked list may be LIFO (last-in-first-out) or FIFO (first-in-first-out). If the list is using the LIFO method, the nodes will be added to and deleted from the same end. If it&#8217;s using FIFO, nodes will be added to one end and deleted from the opposite end. Additionally, the linked list may be sorted.<br \/>\n<strong><\/p>\n<li>How do you move to the end of a linked list?<\/li>\n<p><\/strong><br \/>\nA simple solution is to one by one find all occurrences of a given key in the linked list. For every found occurrence, insert it at the end. We do it till all occurrences of the given key are moved to the end.<br \/>\n<strong><\/p>\n<li>What happens if the last node of the linked list carries the address of the first node in its address pointer field?<\/li>\n<p><\/strong><br \/>\nThis variation of linked list is circular linked list, in which the last node in the list points to the first node of the list.<\/ol><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog will describe the efficient approach to move first node to last in linked list. The linked list is one of the most important concepts and data structures to learn while preparing for interviews. Moving the first element of the linked list at the end position will help you to understand the 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-4455","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>Move the first element to the end of the given list | Linked List | Prepbytes<\/title>\n<meta name=\"description\" content=\"Learn the most efficient way to move the first element to the end of the given list. This blog explains the most efficient approach to move the first element to the end of the given 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\/move-the-first-element-to-the-end-of-the-given-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Move the first element to the end of the given list | Linked List | Prepbytes\" \/>\n<meta property=\"og:description\" content=\"Learn the most efficient way to move the first element to the end of the given list. This blog explains the most efficient approach to move the first element to the end of the given list.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-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-08-30T08:38:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-18T07:24:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Move the first element to the end of the given list\",\"datePublished\":\"2021-08-30T08:38:24+00:00\",\"dateModified\":\"2022-11-18T07:24:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/\"},\"wordCount\":916,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/\",\"name\":\"Move the first element to the end of the given list | Linked List | Prepbytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png\",\"datePublished\":\"2021-08-30T08:38:24+00:00\",\"dateModified\":\"2022-11-18T07:24:44+00:00\",\"description\":\"Learn the most efficient way to move the first element to the end of the given list. This blog explains the most efficient approach to move the first element to the end of the given list.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-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\":\"Move the first element to the end of the given 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":"Move the first element to the end of the given list | Linked List | Prepbytes","description":"Learn the most efficient way to move the first element to the end of the given list. This blog explains the most efficient approach to move the first element to the end of the given 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\/move-the-first-element-to-the-end-of-the-given-list\/","og_locale":"en_US","og_type":"article","og_title":"Move the first element to the end of the given list | Linked List | Prepbytes","og_description":"Learn the most efficient way to move the first element to the end of the given list. This blog explains the most efficient approach to move the first element to the end of the given list.","og_url":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-08-30T08:38:24+00:00","article_modified_time":"2022-11-18T07:24:44+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Move the first element to the end of the given list","datePublished":"2021-08-30T08:38:24+00:00","dateModified":"2022-11-18T07:24:44+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/"},"wordCount":916,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/","url":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/","name":"Move the first element to the end of the given list | Linked List | Prepbytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png","datePublished":"2021-08-30T08:38:24+00:00","dateModified":"2022-11-18T07:24:44+00:00","description":"Learn the most efficient way to move the first element to the end of the given list. This blog explains the most efficient approach to move the first element to the end of the given list.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-list\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644916706727-84move-the-first-element_Artboard%203.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/move-the-first-element-to-the-end-of-the-given-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":"Move the first element to the end of the given 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\/4455","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=4455"}],"version-history":[{"count":9,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4455\/revisions"}],"predecessor-version":[{"id":10583,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/4455\/revisions\/10583"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=4455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=4455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=4455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}