{"id":3997,"date":"2021-08-19T11:42:04","date_gmt":"2021-08-19T11:42:04","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=3997"},"modified":"2022-03-12T00:25:24","modified_gmt":"2022-03-12T00:25:24","slug":"remove-every-kth-node-of-the-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/","title":{"rendered":"Remove every Kth node of the Linked list"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png\" alt=\"\" \/><\/p>\n<h3>Introduction<\/h3>\n<p>The linked list is one of the most important concepts and data structures to learn while preparing for interviews. Having a good grasp of Linked Lists can be a huge plus point in a coding interview.<\/p>\n<\/p>\n<h3>Problem Statement<\/h3>\n<p>Given a singly linked list and a value K, the task is to remove every Kth node of the linked list.<\/p>\n<h3>Problem Statement Understanding<\/h3>\n<p>Let\u2019s try to understand the problem statement with help of example.<\/p>\n<p>We have been given a linked list, our task is to remove every K<sup>th<\/sup> node from the linked list.<\/p>\n<p>To understand the question thoroughly, see the given input below. In this input, the given value of K is 2. So, we have to delete every 2<sup>nd<\/sup> node of the linked list which are 23, 11, and 6.<\/p>\n<h4>Example:<\/h4>\n<p><strong>Input:<\/strong> <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/input-1-7.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-1.png\" alt=\"\" \/><\/p>\n<p><strong>Explanation:<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Remove-every-Kth-node-of-the-Linked-list-1.png\" alt=\"\" \/><\/p>\n<p>I think from the above example the problem statement is clear, so we should now think how we can approach this problem. Try to come up with a approach, it may be bruteforce but before jumping to approach section try to think how will you approach it.<\/p>\n<h3>Approach<\/h3>\n<p>The idea is to traverse the list from the beginning and if the index of the current node is divisible by K, then delete the current node.<\/p>\n<h3>Algorithm<\/h3>\n<ul>\n<li>Take two pointer variables, current and previous.<\/li>\n<li>Initialize the current = head and previous = NULL.<\/li>\n<li>If the current node\u2019s index is divisible by K, then delete this node and move current = current\u2192next.<\/li>\n<li>If the current node\u2019s index is not divisible by K, then move previous = current and current = current\u2192next.<\/li>\n<\/ul>\n<h3>Dry Run<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Remove-every-Kth-node-of-the-Linked-list-2.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Remove-every-Kth-node-of-the-Linked-list-3.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/08\/Remove-every-Kth-node-of-the-Linked-list-4.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_3998 {\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_3998 .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_3998 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_3998 .wpsm_nav-tabs > li.active > a, #tab_container_3998 .wpsm_nav-tabs > li.active > a:hover, #tab_container_3998 .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_3998 .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_3998 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_3998 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_3998 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_3998 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_3998 .wpsm_nav-tabs > li > a:hover , #tab_container_3998 .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_3998 .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_3998 .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_3998 .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_3998 .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_3998 .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_3998 .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_3998 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3998 .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_3998 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_3998 .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_3998 .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_3998\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_3998\">\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_3998_1\" aria-controls=\"tabs_desc_3998_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_3998_2\" aria-controls=\"tabs_desc_3998_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_3998_3\" aria-controls=\"tabs_desc_3998_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_3998_4\" aria-controls=\"tabs_desc_3998_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_3998\">\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_3998_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{\r\n    int data;\r\n    struct Node* next;\r\n};\r\n \r\n\/\/ To remove complete list (Needed for\r\n\/\/ case when k is 1)\r\nvoid freeList(struct Node *node)\r\n{\r\n    while (node != NULL)\r\n    {\r\n        struct Node *next = node-&gt;next;\r\n        free(node);\r\n        node  = next;\r\n    }\r\n}\r\n \r\n\/\/ Deletes every k-th node and returns head\r\n\/\/ of modified list.\r\nstruct Node *deleteKthNode(struct Node *head, int k)\r\n{\r\n    \/\/ If linked list is empty\r\n    if (head == NULL)\r\n        return NULL;\r\n \r\n    if (k == 1)\r\n    {\r\n       freeList(head);\r\n       return NULL;\r\n    }\r\n \r\n    \/\/ Initialize ptr and prev before starting\r\n    \/\/ traversal.\r\n    struct Node *ptr = head, *prev = NULL;\r\n \r\n    \/\/ Traverse list and delete every k-th node\r\n    int count = 0;\r\n    while (ptr != NULL)\r\n    {\r\n        \/\/ increment Node count\r\n        count++;\r\n \r\n        \/\/ check if count is equal to k\r\n        \/\/ if yes, then delete current Node\r\n        if (k == count)\r\n        {\r\n            \/\/ put the next of current Node in\r\n            \/\/ the next of previous Node\r\n            free(prev-&gt;next);\r\n            prev-&gt;next = ptr-&gt;next;\r\n \r\n            \/\/ set count = 0 to reach further\r\n            \/\/ k-th Node\r\n            count = 0;\r\n        }\r\n \r\n        \/\/ update prev if count is not 0\r\n        if (count != 0)\r\n            prev = ptr;\r\n \r\n        ptr = prev-&gt;next;\r\n    }\r\n \r\n    return head;\r\n}\r\n \r\n\/* Function to print linked list *\/\r\nvoid displayList(struct Node *head)\r\n{\r\n    struct Node *temp = head;\r\n    while (temp != NULL)\r\n    {\r\n        printf(&quot;%d &quot;,temp-&gt;data);\r\n        temp = temp-&gt;next;\r\n    }\r\n}\r\n \r\n\/\/ Utility function to create a new node.\r\nstruct Node *newNode(int x)\r\n{\r\n    struct Node* temp =\r\n         (struct Node*)malloc(sizeof(struct Node));\r\n    temp-&gt;data = x;\r\n    temp-&gt;next = NULL;\r\n    return temp;\r\n}\r\n \r\n\/* Driver program to test count function*\/\r\nint main()\r\n{\r\n    \/* Start with the empty list *\/\r\n    struct Node* head = newNode(1);\r\n    head-&gt;next = newNode(2);\r\n    head-&gt;next-&gt;next = newNode(3);\r\n    head-&gt;next-&gt;next-&gt;next = newNode(4);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next = newNode(5);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next = newNode(6);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next =\r\n                                        newNode(7);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next =\r\n                                        newNode(8);\r\n    int k = 3;\r\n    head = deleteKthNode(head, k);\r\n \r\n    displayList(head);\r\n \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_3998_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\nstruct Node {\r\n    int data;\r\n    struct Node* next;\r\n};\r\n\r\nNode* deleteKthNode(Node *head,int K)\r\n{\r\n  Node *curr = head, *prv = NULL;\r\n  int index = 1;\r\n  \/* Edge case \r\n  If K = 1 means every node has to be deleted\r\n    that is why we first delete every node and\r\n    then return the empty Linked list as NULL. *\/\r\n  if(K==1){\r\n      delete head;\r\n      return NULL;\r\n  }\r\n  while(curr!=NULL){\r\n      \/* If current node&rsquo;s index is divisible \r\n         by K then, delete the current Node.*\/\r\n      if(index%K==0){\r\n          Node* temp = curr;\r\n          curr = curr-&gt;next;\r\n          prv-&gt;next=curr;\r\n          temp-&gt;next=NULL;\r\n          delete temp;\r\n      }else{\r\n          prv = curr;\r\n          curr = curr-&gt;next;\r\n      }\r\n      index++;\r\n  }\r\n  return head;\r\n}\r\n\r\n\r\nvoid push(struct Node** head_ref, int new_data)\r\n{\r\n    struct Node* new_node = new 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\nint main()\r\n{\r\n\r\n    Node* head = NULL;\r\n    push(&amp;head, 19);\r\n    push(&amp;head, 6);\r\n    push(&amp;head, 15);\r\n    push(&amp;head, 11);\r\n    push(&amp;head, 3);\r\n    push(&amp;head, 23);\r\n    push(&amp;head, 1);\r\n    cout&lt;&lt;&quot;Original Linked List: &quot;&lt;&lt;endl;\r\n    for (Node* temp = head; temp != NULL; temp = temp-&gt;next)\r\n        cout &lt;&lt; temp-&gt;data &lt;&lt; &quot; &quot;;\r\n    cout&lt;&lt;endl;\r\n    int K = 2;\r\n    head = deleteKthNode(head,K);\r\n    cout&lt;&lt;&quot;Linked List after removing every Kth node of the original linked list: &quot;&lt;&lt;endl;\r\n    for (Node* temp = head; temp != NULL; temp = temp-&gt;next)\r\n        cout &lt;&lt; temp-&gt;data &lt;&lt; &quot; &quot;;\r\n \r\n    return 0;\r\n}\r\n\r\n\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_3998_3\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"Java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"Java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nclass KNode\r\n{\r\n    static class Node\r\n    {\r\n\t    int data;\r\n\t    Node next;\r\n    }\r\n    \/\/ To remove complete list (Needed for case when k is 1)\r\n    static Node freeList(Node node)\r\n    {\r\n\t    while (node != null)\r\n\t    {\r\n\t\t    Node next = node.next;\r\n\t\t    node = next;\r\n\t    }\r\n\t    return node;\r\n    }\r\n    \/\/ Deletes every k-th node and returns head of modified list.\r\n    static Node deleteKthNode(Node head, int k)\r\n    {\r\n\t    \/\/ If linked list is empty\r\n\t    if (head == null)\r\n\t\t    return null;\r\n\r\n\t    if (k == 1)\r\n\t    {\r\n\t\t    head = freeList(head);\r\n\t\t    return null;\r\n\t    }\r\n        \/\/ Initialize ptr and prev before starting traversal.\r\n\t    Node ptr = head, prev = null;\r\n\r\n\t    \/\/ Traverse list and delete every k-th node\r\n\t    int count = 0;\r\n\t    while (ptr != null)\r\n\t    {\r\n\t\t    \/\/ increment Node count\r\n\t\t    count++;\r\n\r\n\t\t    \/\/ check if count is equal to k\r\n\t\t    \/\/ if yes, then delete current Node\r\n\t\t    if (k == count)\r\n\t\t    {\r\n\t\t\t    \/\/ put the next of current Node in\r\n\t\t\t    \/\/ the next of previous Node\r\n\t\t\t    prev.next = ptr.next;\r\n\r\n\t\t\t    \/\/ set count = 0 to reach further k-th Node\r\n\t\t\t    count = 0;\r\n\t\t    }\r\n\t\t    \/\/ update prev if count is not 0\r\n\t\t    if (count != 0)\r\n\t\t\t    prev = ptr;\r\n\r\n\t\t    ptr = prev.next;\r\n\t    }\r\n\t    return head;\r\n    }\r\n    static void displayList(Node head)\r\n    {\r\n\t    Node temp = head;\r\n\t    while (temp != null)\r\n\t    {\r\n\t\t    System.out.print(temp.data + &quot; &quot;);\r\n\t\t    temp = temp.next;\r\n\t    }\r\n    }\r\n    static Node newNode(int x)\r\n    {\r\n\t    Node temp = new Node();\r\n\t    temp.data = x;\r\n\t    temp.next = null;\r\n\t    return temp;\r\n    }\r\n    public static void main(String args[])\r\n    {\r\n\t    \/* Start with the empty list *\/\r\n\t    Node head = newNode(1);\r\n\t    head.next = newNode(2);\r\n\t    head.next.next = newNode(3);\r\n\t    head.next.next.next = newNode(4);\r\n\t    head.next.next.next.next = newNode(5);\r\n\t    head.next.next.next.next.next = newNode(6);\r\n\r\n\t    int k = 3;\r\n\t    head = deleteKthNode(head, k);\r\n\r\n\t    displayList(head);\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_3998_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\ndef freeList(node):\r\n\twhile (node != None):\r\n\t\tnext = node.next\r\n\t\tnode = next\r\n\treturn node\r\n\r\ndef deleteKthNode(head, k):\r\n\t\r\n\tif (head == None):\r\n\t\treturn None\r\n\r\n\tif (k == 1):\r\n\t\tfreeList(head)\r\n\t\treturn None\r\n\t\r\n\tptr = head\r\n\tprev = None\r\n\tcount = 0\r\n\twhile (ptr != None):\r\n\t\t\r\n\t\tcount = count + 1\r\n\r\n\t\tif (k == count):\r\n\t\t\tprev.next = ptr.next\r\n\t\t\tcount = 0\r\n\r\n\t\tif (count != 0):\r\n\t\t\tprev = ptr\r\n\r\n\t\tptr = prev.next\r\n\t\r\n\treturn head\r\n\r\ndef displayList(head):\r\n\ttemp = head\r\n\twhile (temp != None):\r\n\t\tprint(temp.data, end = ' ')\r\n\t\ttemp = temp.next\r\n\t\r\ndef newNode( x):\r\n\ttemp = Node(x)\r\n\ttemp.data = x\r\n\ttemp.next = None\r\n\treturn temp\r\n\r\nif __name__=='__main__':\r\n\t\r\n\thead = newNode(1)\r\n\thead.next = newNode(23)\r\n\thead.next.next = newNode(3)\r\n\thead.next.next.next = newNode(11)\r\n\thead.next.next.next.next = newNode(15)\r\n\thead.next.next.next.next.next = newNode(6)\r\n\thead.next.next.next.next.next.next = newNode(9)\r\n\r\n\tk = 2\r\n\thead = deleteKthNode(head, k)\r\n\r\n\tdisplayList(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_3998 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_3998 a\"),jQuery(\"#tab-content_3998\"));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 Linked List:<br \/>\n1 23 3 11 15 6 19<br \/>\nLinked List after removing every Kth node of the original linked list:<br \/>\n1 3 15 19<\/p>\n<p><strong>Time Complexity:<\/strong> O(N), because we have traversed through the linked list once.<br \/>\n[forminator_quiz id=&#8221;3978&#8243;]<\/p>\n<p>So, In this blog, we have learned how to remove every K<sup>th<\/sup> node of the linked list. 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","protected":false},"excerpt":{"rendered":"<p>Introduction The linked list is one of the most important concepts and data structures to learn while preparing for interviews. Having a good grasp of Linked Lists can be a huge plus point in a coding interview. Problem Statement Given a singly linked list and a value K, the task is to remove every Kth [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[125],"tags":[],"class_list":["post-3997","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>Learn to Remove every Kth node of the Linked list with examples<\/title>\n<meta name=\"description\" content=\"Learn the most efficient way to remove every Kth node of the linked list. This blog explains how to remove every Kth node of the 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\/remove-every-kth-node-of-the-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learn to Remove every Kth node of the Linked list with examples\" \/>\n<meta property=\"og:description\" content=\"Learn the most efficient way to remove every Kth node of the linked list. This blog explains how to remove every Kth node of the linked list.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-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-08-19T11:42:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-12T00:25:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/\"},\"author\":{\"name\":\"PrepBytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\"},\"headline\":\"Remove every Kth node of the Linked list\",\"datePublished\":\"2021-08-19T11:42:04+00:00\",\"dateModified\":\"2022-03-12T00:25:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/\"},\"wordCount\":350,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/\",\"name\":\"Learn to Remove every Kth node of the Linked list with examples\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png\",\"datePublished\":\"2021-08-19T11:42:04+00:00\",\"dateModified\":\"2022-03-12T00:25:24+00:00\",\"description\":\"Learn the most efficient way to remove every Kth node of the linked list. This blog explains how to remove every Kth node of the linked list.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-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\":\"Remove every Kth node of 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\/39fcf072e04987f16796546f2ca83c2e\",\"name\":\"PrepBytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"caption\":\"PrepBytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Learn to Remove every Kth node of the Linked list with examples","description":"Learn the most efficient way to remove every Kth node of the linked list. This blog explains how to remove every Kth node of the 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\/remove-every-kth-node-of-the-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Learn to Remove every Kth node of the Linked list with examples","og_description":"Learn the most efficient way to remove every Kth node of the linked list. This blog explains how to remove every Kth node of the linked list.","og_url":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-08-19T11:42:04+00:00","article_modified_time":"2022-03-12T00:25:24+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png","type":"","width":"","height":""}],"author":"PrepBytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"PrepBytes","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/"},"author":{"name":"PrepBytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e"},"headline":"Remove every Kth node of the Linked list","datePublished":"2021-08-19T11:42:04+00:00","dateModified":"2022-03-12T00:25:24+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/"},"wordCount":350,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/","name":"Learn to Remove every Kth node of the Linked list with examples","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png","datePublished":"2021-08-19T11:42:04+00:00","dateModified":"2022-03-12T00:25:24+00:00","description":"Learn the most efficient way to remove every Kth node of the linked list. This blog explains how to remove every Kth node of the linked list.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-the-linked-list\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1644925883878-104.Remove%20every%20Kth%20node-05.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/remove-every-kth-node-of-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":"Remove every Kth node of 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\/39fcf072e04987f16796546f2ca83c2e","name":"PrepBytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","caption":"PrepBytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=3997"}],"version-history":[{"count":7,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3997\/revisions"}],"predecessor-version":[{"id":7827,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/3997\/revisions\/7827"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=3997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=3997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=3997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}