{"id":5804,"date":"2021-10-25T10:04:33","date_gmt":"2021-10-25T10:04:33","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=5804"},"modified":"2022-11-28T06:54:27","modified_gmt":"2022-11-28T06:54:27","slug":"check-if-linked-list-is-palindrome","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/","title":{"rendered":"Check If Linked List Is Palindrome"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png\" alt=\"\" \/><\/p>\n<p>Linked is an important concept of data structures for placement point of view. In an interview, almost all the questions asked related to the linked list. One of the most frequently asked problems \u201ccheck if linked list is palindrome\u201d  is the one from them and top product-based companies like Amazon, Accenture, flipkart, Adobe, and many more.<\/p>\n<h2>How to check if linked list is palindrome<\/h2>\n<p>We will be given a linked list, and we need to find whether the given list is palindrome or not.<\/p>\n<p>To understand this problem statement, let us take examples.<\/p>\n<p>If the given linked list is 3\u21921\u219218\u21921\u21923\u2192NULL, and now according to the problem statement, we need to determine whether the given linked list is palindrome or not.<\/p>\n<ul>\n<li>If we iterate the given list forward and print the elements, we will get: 3,1,18,1,3<\/li>\n<li>Now, if we iterate the given list backward and print the elements, we will get: 3,1,18,1,3.<\/li>\n<li>We can see that no matter we iterate forward or backward, we are getting the same output at the end. So, the given list is a palindrome.<\/li>\n<\/ul>\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 1 to check if linked list is palindrome<\/h2>\n<p>To check whether a linked list is a palindrome or not, we need to traverse the list backward from the last node of the list, but as our linked list is a singly linked list, we cannot move backwards in the list.<br \/>\nTo solve the above problem, we will use a stack and store all the elements of the list in the stack while forward iteration of the list.<\/p>\n<ul>\n<li>After that, we will again iterate the list and will simultaneously pop an element from the stack at each iteration and will check if this popped element is equal to the current element of the list or not.<\/li>\n<li>If all the elements are equal, then the list is a palindrome. Else, It is not a palindrome.<\/li>\n<\/ul>\n<p><strong>Time Complexity to check if linked list is palindrome:<\/strong> O(n), where n is the total number of nodes in the list<\/p>\n<p><strong>Space Complexity to check if linked list is palindrome:<\/strong> O(n), due to the stack<\/p>\n<p>The above approach seems fine, but we are using a stack that is increasing the space complexity. So, we need to think of a better approach where no extra space is used.<\/p>\n<h2>Approach 2 to check if linked list is palindrome<\/h2>\n<p>Since we cannot move backward in the list, we need to devise an algorithm to get our work done.<br \/>\nWe can reverse the second half of the list and then simultaneously compare the elements from the first and second half of the list.<\/p>\n<ul>\n<li>If all elements of first and the second half are equal, then the list is a palindrome.<\/li>\n<li>Else, the list is not a palindrome.<\/li>\n<\/ul>\n<h2>Algorithm to check if linked list is palindrome<\/h2>\n<ol>\n<li>If the list is empty or it has only one node then simply return true as an empty list or a list with a single node is always a palindrome.<\/li>\n<li>Initialize two pointers <strong>slow<\/strong> and <strong>fast<\/strong> with the first node of the list (finding the middle node of the linked list).\n<ul>\n<li>Run a while loop till the <strong>fast<\/strong> reach the last or last second node of the list.<\/li>\n<li>In each iteration, advance <strong>slow<\/strong> forward by one node and <strong>fast<\/strong>  forward by two nodes.<\/li>\n<li>Now, when the <strong>fast<\/strong> is at the end of the list, <strong>slow<\/strong> will be pointing to the middle node of the linked list.<\/li>\n<\/ul>\n<\/li>\n<li>Now, reverse the second half of the linked list starting from <strong>slow-&gt;next<\/strong> to the last node of the linked list.<\/li>\n<li>After that, simultaneously iterate through the first half and the second half of the linked list using pointers <strong>head<\/strong> and <strong>slow<\/strong>:\n<ul>\n<li>If the data of the node to which <strong>head<\/strong> and <strong>slow<\/strong> are pointing are not equal, return false.<\/li>\n<li>Else, advance <strong>slow<\/strong> and <strong>head<\/strong> by one node.<\/li>\n<\/ul>\n<\/li>\n<li>After execution of the above while loop, return true from the function.<\/li>\n<\/ol>\n<h3>Dry Run to check if linked list is palindrome <\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_1.jpg\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_2.jpg\" alt=\"\" \/><\/p>\n<h2>Code Implementation to check if linked list is palindrome<\/h2>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5807 {\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_5807 .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_5807 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5807 .wpsm_nav-tabs > li.active > a, #tab_container_5807 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5807 .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_5807 .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_5807 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5807 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5807 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5807 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5807 .wpsm_nav-tabs > li > a:hover , #tab_container_5807 .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_5807 .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_5807 .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_5807 .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_5807 .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_5807 .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_5807 .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_5807 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5807 .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_5807 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5807 .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_5807 .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_5807\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5807\">\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_5807_1\" aria-controls=\"tabs_desc_5807_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_5807_2\" aria-controls=\"tabs_desc_5807_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_5807_3\" aria-controls=\"tabs_desc_5807_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_5807_4\" aria-controls=\"tabs_desc_5807_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_5807\">\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_5807_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;stdbool.h&gt;  \r\n   \r\n\/\/Represent a node of the singly linked list  \r\nstruct node{  \r\n    int data;  \r\n    struct node *next;  \r\n};      \r\n   \r\n\/\/Represent the head and tail of the singly linked list  \r\nstruct node *head, *tail = NULL;  \r\nint size = 0;  \r\n   \r\n\/\/addNode() will add a new node to the list  \r\nvoid addNode(int data) {  \r\n    \/\/Create a new node  \r\n    struct node *newNode = (struct node*)malloc(sizeof(struct node));  \r\n    newNode-&gt;data = data;  \r\n    newNode-&gt;next = NULL;  \r\n      \r\n    \/\/Checks if the list is empty  \r\n    if(head == NULL) {  \r\n        \/\/If list is empty, both head and tail will point to new node  \r\n        head = newNode;  \r\n        tail = newNode;  \r\n    }  \r\n    else {  \r\n        \/\/newNode will be added after tail such that tail's next will point to newNode  \r\n        tail-&gt;next = newNode;  \r\n        \/\/newNode will become new tail of the list  \r\n        tail = newNode;  \r\n    }  \r\n    \/\/Size will count the number of nodes present in the list  \r\n    size++;  \r\n}  \r\n   \r\n\/\/reverseList() will reverse the singly linked list and return the head of the list  \r\nstruct node* reverseList(struct node *temp){  \r\n    struct node *current = temp;  \r\n    struct node *prevNode = NULL, *nextNode = NULL;  \r\n      \r\n   \/\/Swap the previous and next nodes of each node to reverse the direction of the list  \r\n    while(current != NULL){  \r\n        nextNode = current-&gt;next;  \r\n        current-&gt;next = prevNode;  \r\n        prevNode = current;  \r\n        current = nextNode;  \r\n    }  \r\n    return prevNode;  \r\n}  \r\n   \r\n\/\/isPalindrome() will determine whether given list is palindrome or not.  \r\nvoid isPalindrome(){  \r\n    struct node *current = head;  \r\n    bool flag = true;  \r\n      \r\n    \/\/Store the mid position of the list  \r\n    int mid = (size%2 == 0)? (size\/2) : ((size+1)\/2);  \r\n      \r\n    \/\/Finds the middle node in given singly linked list  \r\n    for(int i=1; i&lt;mid; i++){=&quot;&quot; current=&quot;current-&quot;&gt;next;  \r\n    }  \r\n      \r\n    \/\/Reverse the list after middle node to end  \r\n    struct node *revHead = reverseList(current-&gt;next);  \r\n   \r\n    \/\/Compare nodes of first half and second half of list  \r\n    while(head != NULL &amp;&amp; revHead != NULL){  \r\n        if(head-&gt;data != revHead-&gt;data){  \r\n            flag = false;  \r\n            break;  \r\n        }  \r\n        head = head-&gt;next;  \r\n        revHead = revHead-&gt;next;  \r\n    }  \r\n   \r\n    if(flag)  \r\n        printf(&quot;Given singly linked list is a palindrome&#92;n&quot;);  \r\n    else  \r\n        printf(&quot;Given singly linked list is not a palindrome&#92;n&quot;);  \r\n}  \r\n      \r\n\/\/display() will display all the nodes present in the list  \r\nvoid display() {  \r\n    \/\/Node current will point to head  \r\n    struct node *current = head;  \r\n      \r\n    if(head == NULL) {  \r\n        printf(&quot;List is empty&#92;n&quot;);  \r\n        return;  \r\n    }  \r\n    printf(&quot;Nodes of singly linked list: &#92;n&quot;);  \r\n    while(current != NULL) {  \r\n        \/\/Prints each node by incrementing pointer  \r\n        printf(&quot;%d &quot;, current-&gt;data);  \r\n        current = current-&gt;next;  \r\n    }  \r\n    printf(&quot;&#92;n&quot;);  \r\n}  \r\n      \r\nint main()  \r\n{  \r\n    \/\/Add nodes to the list  \r\n    addNode(1);  \r\n    addNode(2);  \r\n    addNode(3);  \r\n    addNode(2);  \r\n    addNode(2);  \r\n      \r\n    display();  \r\n      \r\n    \/\/Checks whether given list is palindrome or not  \r\n    isPalindrome();  \r\n      \r\n    return 0;  \r\n}  \r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_5807_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\n\r\nclass Node{\r\n    public:\r\n    int data;\r\n    Node* next;\r\n    Node(int x){\r\n        data = x;\r\n        next = NULL;\r\n    }\r\n};\r\n\r\n\/\/ This function will reverse the list\r\nNode* reverse(Node *head)\r\n{\r\n    Node *prev = NULL, *current = head, *next;\r\n    while (current != NULL)\r\n    {\r\n        next  = current-&gt;next;\r\n        current-&gt;next = prev;\r\n        prev = current;\r\n        current = next;\r\n    }\r\n    return prev;\r\n}\r\n\r\n\/\/ This function checks if a list is palindrome \r\nbool isPalindrome(Node* head) {\r\n    \/\/check if the list is empty or \r\n    \/\/it has a single node\r\n    if(head==NULL||head-&gt;next==NULL)\r\n        return true;\r\n\r\n    \/\/initialize two pointers \r\n    Node* slow=head;\r\n    Node* fast=head;\r\n\r\n    \/\/ find the middle node of the list\r\n    while(fast-&gt;next!=NULL&amp;&amp;fast-&gt;next-&gt;next!=NULL){\r\n        slow=slow-&gt;next;\r\n        fast=fast-&gt;next-&gt;next;\r\n    }\r\n\r\n    \/\/ reverse the second half of the list\r\n    slow-&gt;next=reverse(slow-&gt;next);\r\n\r\n    \/\/update the 'slow' pointer\r\n    slow=slow-&gt;next;\r\n\r\n    \/\/iterate both the lists simultaneously\r\n    while(slow!=NULL){\r\n        if(head-&gt;data!=slow-&gt;data)\r\n            return false;\r\n        head=head-&gt;next;\r\n        slow=slow-&gt;next;\r\n    }\r\n    return true;\r\n}\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(18);\r\n    head-&gt;next-&gt;next-&gt;next = new Node(1);\r\n    head-&gt;next-&gt;next-&gt;next-&gt;next = new Node(3);\r\n    \r\n    if(isPalindrome(head)){\r\n        cout&lt;&lt;&quot;The list is a palindrome&quot;;\r\n    }else{\r\n        cout&lt;&lt;&quot;The list is not a palindrome&quot;;\r\n    }\r\n    return 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_5807_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 Node{\r\n    int data;\r\n    Node next;\r\n    Node(int x){\r\n        data = x;\r\n    }\r\n}\r\npublic class Palindrome\r\n{\r\n    \/\/ This function will reverse the list\r\n    static Node reverse(Node head)\r\n    {\r\n        Node prev =null, current = head, next=null;\r\n        while (current != null)\r\n        {\r\n            next  = current.next;\r\n            current.next = prev;\r\n            prev = current;\r\n            current = next;\r\n        }\r\n        return prev;\r\n    }\r\n    \/\/ This function checks if a list is palindrome \r\n    static boolean isPalindrome(Node head) \r\n    {\r\n        \/\/check if the list is empty or \r\n        \/\/it has a single node\r\n        if(head==null||head.next==null)\r\n            return true;\r\n\r\n        \/\/initialize two pointers \r\n        Node slow=head;\r\n        Node fast=head;\r\n\r\n        \/\/ find the middle node of the list\r\n        while(fast.next!=null &amp;&amp; fast.next.next!=null){\r\n            slow=slow.next;\r\n            fast=fast.next.next;\r\n        }\r\n\r\n        \/\/ reverse the second half of the list\r\n        slow.next=reverse(slow.next);\r\n\r\n        \/\/update the 'slow' pointer\r\n        slow=slow.next;\r\n\r\n        \/\/iterate both the lists simultaneously\r\n        while(slow!=null){\r\n            if(head.data!=slow.data)\r\n            return false;\r\n            head=head.next;\r\n            slow=slow.next;\r\n        }\r\n        return true;\r\n    }\r\n    public static void main(String[] args) {\r\n        Node head = null;\r\n        head = new Node(3);\r\n        head.next = new Node(1);\r\n        head.next.next = new Node(18);\r\n        head.next.next.next = new Node(1);\r\n        head.next.next.next.next = new Node(3);\r\n        \r\n        if(isPalindrome(head)){\r\n           System.out.println(&quot;List is palindrome&quot;);\r\n        }else{\r\n            System.out.println(&quot;List is not palindrome&quot;);\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_5807_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    def __init__(self,data):\r\n        \r\n        self.data = data\r\n        self.next = None\r\n        \r\n# This function will reverse the list\r\ndef reverse(head):\r\n    prev = None\r\n    current = head\r\n    while(current is not None):\r\n        next = current.next\r\n        current.next = prev\r\n        prev = current\r\n        current = next\r\n    head = prev\r\n    return head\r\n\r\n# This function checks if a list is palindrome \r\ndef ispalindrome(head):\r\n\r\n    # check if the list is empty or it has a single node\r\n    if head == None or head.next == None:\r\n        return True\r\n    \r\n    # initialize two pointers\r\n    slow = head\r\n    fast = head\r\n\r\n    # find the middle node of the list\r\n    while fast.next and fast.next.next:\r\n        slow = slow.next\r\n        fast = fast.next.next\r\n\r\n    # reverse the second half of the list\r\n    slow.next = reverse(slow.next)\r\n\r\n    # update the 'slow' pointer\r\n    slow = slow.next\r\n\r\n    # iterate both the lists simultaneously\r\n    while slow:\r\n        if head.data != slow.data:\r\n            return False\r\n        head = head.next\r\n        slow = slow.next\r\n    return True\r\n\r\n\r\nhead = None\r\nhead = Node(3)\r\nhead.next = Node(1)\r\nhead.next.next = Node(18)\r\nhead.next.next.next = Node(1)\r\nhead.next.next.next.next = Node(3)\r\n\r\nif ispalindrome(head):\r\n    print(&quot;The list is a palindrome&quot;)\r\nelse:\r\n    print(&quot;The list is not a palindrome&quot;)\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\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_5807 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_5807 a\"),jQuery(\"#tab-content_5807\"));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\nThe list is a palindrome<\/code><\/pre>\n<p><strong>Time Complexity to check if linked list is palindrome:<\/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 you can check if linked list is palindrome most optimally. If you are new to programming and want to learn more about programming languages, also 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 check if linked list is palindrome<\/h2>\n<p><strong>1. What is the meaning of palindromic?<\/strong><br \/>\nA palindrome is a word that reads the same backward and forward. The words, numbers, and sequences which satisfy the palindrome property are called palindromic.<br \/>\nExamples: Words like RADAR, CIVIC, and Numbers like 121, 1331.<\/p>\n<p><strong>2. What is a palindrome number?<\/strong><br \/>\nNumbers that read the same backward and forward are called palindrome numbers. The numbers 17371, 3, and 121 are palindrome numbers.<\/p>\n<p><strong>3. How do you check if a palindrome is valid in Python?<\/strong><br \/>\nTo check whether the string is a valid palindrome or not using a regular expression you have to make use of re. sub() on a set of alphanumeric characters which needs to be replaced with lowercase characters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linked is an important concept of data structures for placement point of view. In an interview, almost all the questions asked related to the linked list. One of the most frequently asked problems \u201ccheck if linked list is palindrome\u201d is the one from them and top product-based companies like Amazon, Accenture, flipkart, Adobe, and many [&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-5804","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>Linked List | Check If Linked List Is Palindrome | Prepbytes<\/title>\n<meta name=\"description\" content=\"Learn how to check if a linked list is a palindrome.\" \/>\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\/check-if-linked-list-is-palindrome\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linked List | Check If Linked List Is Palindrome | Prepbytes\" \/>\n<meta property=\"og:description\" content=\"Learn how to check if a linked list is a palindrome.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/\" \/>\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:04:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-28T06:54:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.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\/check-if-linked-list-is-palindrome\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Check If Linked List Is Palindrome\",\"datePublished\":\"2021-10-25T10:04:33+00:00\",\"dateModified\":\"2022-11-28T06:54:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/\"},\"wordCount\":940,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png\",\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/\",\"name\":\"Linked List | Check If Linked List Is Palindrome | Prepbytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png\",\"datePublished\":\"2021-10-25T10:04:33+00:00\",\"dateModified\":\"2022-11-28T06:54:27+00:00\",\"description\":\"Learn how to check if a linked list is a palindrome.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#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\":\"Check If Linked List Is Palindrome\"}]},{\"@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":"Linked List | Check If Linked List Is Palindrome | Prepbytes","description":"Learn how to check if a linked list is a palindrome.","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\/check-if-linked-list-is-palindrome\/","og_locale":"en_US","og_type":"article","og_title":"Linked List | Check If Linked List Is Palindrome | Prepbytes","og_description":"Learn how to check if a linked list is a palindrome.","og_url":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-10-25T10:04:33+00:00","article_modified_time":"2022-11-28T06:54:27+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.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\/check-if-linked-list-is-palindrome\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Check If Linked List Is Palindrome","datePublished":"2021-10-25T10:04:33+00:00","dateModified":"2022-11-28T06:54:27+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/"},"wordCount":940,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png","articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/","url":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/","name":"Linked List | Check If Linked List Is Palindrome | Prepbytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png","datePublished":"2021-10-25T10:04:33+00:00","dateModified":"2022-11-28T06:54:27+00:00","description":"Learn how to check if a linked list is a palindrome.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645012115383-Article_200.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/check-if-linked-list-is-palindrome\/#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":"Check If Linked List Is Palindrome"}]},{"@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\/5804","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=5804"}],"version-history":[{"count":5,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5804\/revisions"}],"predecessor-version":[{"id":10779,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5804\/revisions\/10779"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=5804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=5804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=5804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}