// API callback
related_results_labels_thumbs({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385"},"updated":{"$t":"2023-12-09T13:35:10.032-08:00"},"category":[{"term":"cpp"},{"term":"c++"},{"term":"hackerrank"},{"term":"c++ program"},{"term":"Linked Lists in C++"},{"term":"c"},{"term":"c programming"},{"term":"programming"},{"term":"PATTERNS"},{"term":"coding"},{"term":"C++ Diamond Pattern"},{"term":"Hackerrank Delete duplicate-value nodes from a sorted linked list Solution"},{"term":"Hackerrank Insert a node into a sorted doubly linked list Solution"},{"term":"Hackerrank Print in Reverse solution"},{"term":"Hackerrank Print the elements of a linked list solution"},{"term":"Hackerrank Reverse a doubly linked list solution"},{"term":"TEXT ANALYZER"},{"term":"Utopian tree"},{"term":"education"},{"term":"hourglass pattern c++"},{"term":"java"},{"term":"java program"},{"term":"lexical analyser"},{"term":"mini project"},{"term":"networks"},{"term":"operator precedence"},{"term":"opps sandclock pattern"},{"term":"opps triangle pattern"},{"term":"pattern generation in c"},{"term":"triangle pattern c++"},{"term":"unipolar encoding simulation"}],"title":{"type":"text","$t":"GRK"},"subtitle":{"type":"html","$t":"A blog by Gokul Raj Kumar"},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https:\/\/blog.grkweb.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/-\/cpp?alt=json-in-script\u0026max-results=6"},{"rel":"alternate","type":"text/html","href":"https:\/\/blog.grkweb.com\/search\/label\/cpp"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"},{"rel":"next","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/-\/cpp\/-\/cpp?alt=json-in-script\u0026start-index=7\u0026max-results=6"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"9"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"6"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385.post-1975582297260883170"},"published":{"$t":"2015-09-23T09:45:00.004-07:00"},"updated":{"$t":"2022-01-16T10:02:25.928-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"c++"},{"scheme":"http://www.blogger.com/atom/ns#","term":"c++ program"},{"scheme":"http://www.blogger.com/atom/ns#","term":"coding"},{"scheme":"http://www.blogger.com/atom/ns#","term":"cpp"},{"scheme":"http://www.blogger.com/atom/ns#","term":"hackerrank"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Hackerrank Insert a node into a sorted doubly linked list Solution"}],"title":{"type":"text","$t":"Insert a node into a sorted doubly linked list Solution"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Cstrong style=\"background-color: white; border: 0px; color: #39424e; font-family: \u0026quot;Whitney SSm A\u0026quot;, \u0026quot;Whitney SSm B\u0026quot;, verdana, \u0026quot;Lucida Grande\u0026quot;, sans-serif; font-size: 18px; font-stretch: inherit; line-height: 27px; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;\"\u003EProblem Statement\u003C\/strong\u003E\u003C\/h2\u003E\nYou’re given the pointer to the head node of a sorted doubly linked list and an integer to insert into the list. Create a node and insert it into the appropriate position in the list. The head node might be NULL to indicate that the list is empty.\u003Cbr \/\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Cb\u003ESource Code:\u003C\/b\u003E\u003C\/h2\u003E\n\u003Cpre style=\"background-image: URL(http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif); background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"\u003E\u003Ccode style=\"color: black; overflow-wrap: normal; word-wrap: normal;\"\u003E Node* SortedInsert(Node *head,int data)  \n {  \n   \/\/ Complete this function  \n   \/\/ Do not write the main method.   \n   Node *temp = new Node;  \n   temp-\u0026gt;data = data;  \n   temp-\u0026gt;next = NULL;  \n   temp-\u0026gt;prev = NULL;  \n   if(head == NULL){  \n     head = temp;  \n   }else{  \n     Node *temp1 = temp;  \n     temp-\u0026gt;next = head;  \n     head = temp;  \n     while(temp!= NULL){  \n       temp1 = temp;  \n       temp = temp-\u0026gt;next;  \n       if(temp!=NULL){  \n         if(temp1-\u0026gt;data\u0026gt;temp-\u0026gt;data){  \n           int tdata;  \n           tdata = temp1-\u0026gt;data;  \n           temp1-\u0026gt;data = temp-\u0026gt;data;  \n           temp-\u0026gt;data = tdata;  \n         }  \n       }  \n     }  \n   }  \n   return head;  \n }  \n\u003C\/code\u003E\u003C\/pre\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/blog.grkweb.com\/feeds\/1975582297260883170\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/09\/hackerrank-insert-node-into-sorted.html#comment-form","title":"7 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/1975582297260883170"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/1975582297260883170"},{"rel":"alternate","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/09\/hackerrank-insert-node-into-sorted.html","title":"Insert a node into a sorted doubly linked list Solution"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"7"}},{"id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385.post-787642138016423133"},"published":{"$t":"2015-08-05T09:10:00.000-07:00"},"updated":{"$t":"2015-08-05T09:10:36.513-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"c++"},{"scheme":"http://www.blogger.com/atom/ns#","term":"C++ Diamond Pattern"},{"scheme":"http://www.blogger.com/atom/ns#","term":"cpp"},{"scheme":"http://www.blogger.com/atom/ns#","term":"pattern generation in c"},{"scheme":"http://www.blogger.com/atom/ns#","term":"PATTERNS"}],"title":{"type":"text","$t":"C++ Diamond Pattern "},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\nC++ program to print the diamond pattern using '#' symbols. In this program two for loops are used to print the pattern. The first loop prints the upper part to the diamond ( triangle part ). The second for loop prints the lower part of the diamond (an inverted triangle ) . By combining both of the triangles an diamond pattern structure is formed.\u003Cbr \/\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nPROGRAM CODE:\u003C\/h2\u003E\n\u003Cdiv\u003E\n\u003Cpre style=\"background-image: URL(http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"\u003E\u003Ccode style=\"color: black; word-wrap: normal;\"\u003E #include\u0026lt;iostream\u0026gt;  \n using namespace std;  \n  int main()  \n  {  \n    int i,j,k=1,s=6,l;  \n    for(i=0;i\u0026lt;5;i++,k-=2,s-=1)  \n    {  \n      for(l=s-1;l\u0026gt;=0;l--)  \n      cout\u0026lt;\u0026lt;' ';  \n      for(j=k;j\u0026lt;0;j++)  \n        cout\u0026lt;\u0026lt;\"#\";  \n      cout\u0026lt;\u0026lt;endl;  \n   }  \n k = 9;  \n s = 0;  \n for(i=0;i\u0026lt;5;i++,k-=2,s+=1)  \n    {  \n      for(l=s;l\u0026gt;=0;l--)  \n      cout\u0026lt;\u0026lt;' ';  \n      for(j=k;j\u0026gt;0;j--)  \n         cout\u0026lt;\u0026lt;\"#\";  \n      cout\u0026lt;\u0026lt;endl;  \n    }  \n  return 0;  \n  }  \n\u003C\/code\u003E\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nOUTPUT:\u003C\/h2\u003E\n\u003Cdiv\u003E\n\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;#\u003C\/span\u003E\u003Cbr style=\"background-color: white; box-sizing: border-box; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; # # #\u003C\/span\u003E\u003Cbr style=\"background-color: white; box-sizing: border-box; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;# # # # #\u003C\/span\u003E\u003Cbr style=\"background-color: white; box-sizing: border-box; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp;# # # # # # #\u003C\/span\u003E\u003Cbr style=\"background-color: white; box-sizing: border-box; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E# # # # # # # # #\u003C\/span\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp;# # # # # # #\u003C\/span\u003E\u003Cbr style=\"background-color: white; box-sizing: border-box; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; # # # # #\u003C\/span\u003E\u003Cbr style=\"background-color: white; box-sizing: border-box; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; # # #\u003C\/span\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; #\u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Cspan style=\"background-color: white; color: #404040; font-family: 'Roboto Slab', sans-serif; font-size: 15px; line-height: 30px;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Cspan style=\"background-color: white; font-size: 15px; line-height: 30px;\"\u003E\u003Cspan style=\"color: #404040; font-family: Roboto Slab, sans-serif;\"\u003E** The above solution is my own code and it may not be the optimal solution or optimal way to approach the problem. So if you have any optimal approaches feel free to paste the code as the comment below..... :) :) :)\u003C\/span\u003E\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/blog.grkweb.com\/feeds\/787642138016423133\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/08\/c-diamond-pattern.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/787642138016423133"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/787642138016423133"},{"rel":"alternate","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/08\/c-diamond-pattern.html","title":"C++ Diamond Pattern "}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385.post-8139343959882141605"},"published":{"$t":"2015-04-18T08:15:00.006-07:00"},"updated":{"$t":"2022-01-16T10:04:59.553-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"c++"},{"scheme":"http://www.blogger.com/atom/ns#","term":"c++ program"},{"scheme":"http://www.blogger.com/atom/ns#","term":"cpp"},{"scheme":"http://www.blogger.com/atom/ns#","term":"hackerrank"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Hackerrank Print the elements of a linked list solution"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Linked Lists in C++"}],"title":{"type":"text","$t":"Print the elements of a linked list solution"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nProblem Statement\u003C\/h2\u003EYou’re given the pointer to the head node of a linked list and you need to print all its elements in order, one element per line. The head pointer may be null, i.e., it may be an empty list. In that case, don’t print anything!\u003Cbr \/\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nSource code:\u003C\/h2\u003E\n\u003Cpre style=\"background-image: URL(http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif); background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"\u003E\u003Ccode style=\"color: black; overflow-wrap: normal; word-wrap: normal;\"\u003E \/*  \n  Print elements of a linked list on console   \n  head pointer input could be NULL as well for empty list  \n  Node is defined as   \n  struct Node  \n  {  \n    int data;  \n    struct Node *next;  \n  }  \n *\/  \n void Print(Node *head)  \n {  \n  \/\/ This is a \"method-only\" submission.   \n  \/\/ You only need to complete this method.   \n   while(head!=NULL){  \n     cout\u0026lt;\u0026lt;head-\u0026gt;data\u0026lt;\u0026lt;endl;  \n     head = head-\u0026gt;next;  \n   }  \n }  \n\u003C\/code\u003E\u003C\/pre\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/blog.grkweb.com\/feeds\/8139343959882141605\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-print-elements-of-linked.html#comment-form","title":"3 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/8139343959882141605"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/8139343959882141605"},{"rel":"alternate","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-print-elements-of-linked.html","title":"Print the elements of a linked list solution"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"3"}},{"id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385.post-2617565913326339638"},"published":{"$t":"2015-04-18T08:12:00.010-07:00"},"updated":{"$t":"2022-01-16T20:52:21.295-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"c++"},{"scheme":"http://www.blogger.com/atom/ns#","term":"c++ program"},{"scheme":"http://www.blogger.com/atom/ns#","term":"cpp"},{"scheme":"http://www.blogger.com/atom/ns#","term":"hackerrank"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Hackerrank Print in Reverse solution"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Linked Lists in C++"}],"title":{"type":"text","$t":"Print a linked list in Reverse solution"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nProblem Statement\u003C\/h2\u003EYou're given the pointer to the head node of a linked list and you need to print all its elements in reverse order from tail to head, one element per line. The head pointer may be null meaning that the list is empty - in that case, don't print anything!\u003Cbr \/\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nSoruce code:\u003C\/h2\u003E\n\u003Cpre style=\"background-image: URL(http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif); background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"\u003E\u003Ccode style=\"color: black; overflow-wrap: normal; word-wrap: normal;\"\u003E \/*  \n  Print elements of a linked list in reverse order as standard output  \n  head pointer could be NULL as well for empty list  \n  Node is defined as   \n  struct Node  \n  {  \n    int data;  \n    struct Node *next;  \n  }  \n *\/  \n void ReversePrint(Node *head)  \n {  \n  \/\/ This is a \"method-only\" submission.   \n  \/\/ You only need to complete this method.   \n   int a[100],i=0;  \n   while(head!=NULL){  \n     a[i] = head-\u0026gt;data;  \n     i++;  \n     head = head-\u0026gt;next;  \n   }  \n   for(int j = i-1;j\u0026gt;=0;j--){  \n     cout\u0026lt;\u0026lt;a[j]\u0026lt;\u0026lt;endl;  \n   }  \n }  \n\u003C\/code\u003E\u003C\/pre\u003E\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/blog.grkweb.com\/feeds\/2617565913326339638\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-print-in-reverse-solution.html#comment-form","title":"7 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/2617565913326339638"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/2617565913326339638"},{"rel":"alternate","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-print-in-reverse-solution.html","title":"Print a linked list in Reverse solution"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"7"}},{"id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385.post-5457272856518600287"},"published":{"$t":"2015-04-18T08:10:00.004-07:00"},"updated":{"$t":"2022-01-16T20:50:22.970-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"c++"},{"scheme":"http://www.blogger.com/atom/ns#","term":"c++ program"},{"scheme":"http://www.blogger.com/atom/ns#","term":"cpp"},{"scheme":"http://www.blogger.com/atom/ns#","term":"hackerrank"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Hackerrank Reverse a doubly linked list solution"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Linked Lists in C++"}],"title":{"type":"text","$t":"Reverse a doubly linked list solution"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ch2\u003E\nProblem Statement\u003C\/h2\u003E\nYou’re given the pointer to the head node of a doubly linked list. Reverse the order of the nodes in the list. The head node might be NULL to indicate that the list is empty.\u003Cbr \/\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nSource Code:\u003C\/h2\u003E\n\u003Cpre style=\"background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); height: auto; overflow: auto; padding: 0px; text-align: left; width: 99%;\"\u003E\u003Ccode style=\"color: black; font-family: arial; font-size: 12px; line-height: 20px; overflow-wrap: normal; word-wrap: normal;\"\u003E \/*  \n   Reverse a doubly linked list, input list may also be empty  \n   Node is defined as  \n   struct Node  \n   {  \n    int data;  \n    Node *next;  \n    Node *prev;  \n   }  \n *\/  \n Node* Reverse(Node* head)  \n {  \n   Node *cur = head,*temp = new Node;  \n   \/\/ Complete this function  \n   \/\/ Do not write the main method.   \n   while(cur !=NULL){  \n     temp-\u0026gt;next = cur-\u0026gt;next;  \n     temp-\u0026gt;prev = cur-\u0026gt;prev;  \n     cur-\u0026gt;next = temp-\u0026gt;prev;  \n     cur-\u0026gt;prev = temp-\u0026gt;next;  \n     cur = temp-\u0026gt;next;  \n     if(cur!=NULL){  \n       head = cur;  \n     }  \n   }  \n   return head;  \n }  \u003C\/code\u003E\u003C\/pre\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/blog.grkweb.com\/feeds\/5457272856518600287\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-reverse-doubly-linked-list.html#comment-form","title":"8 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/5457272856518600287"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/5457272856518600287"},{"rel":"alternate","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-reverse-doubly-linked-list.html","title":"Reverse a doubly linked list solution"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"8"}},{"id":{"$t":"tag:blogger.com,1999:blog-5735018943946871385.post-7563701694907052843"},"published":{"$t":"2015-04-18T00:38:00.009-07:00"},"updated":{"$t":"2022-01-16T20:49:48.578-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"c++"},{"scheme":"http://www.blogger.com/atom/ns#","term":"c++ program"},{"scheme":"http://www.blogger.com/atom/ns#","term":"cpp"},{"scheme":"http://www.blogger.com/atom/ns#","term":"hackerrank"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Hackerrank Delete duplicate-value nodes from a sorted linked list Solution"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Linked Lists in C++"}],"title":{"type":"text","$t":"Delete duplicate value nodes from a sorted linked list Solution"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Cdiv class=\"msB\" style=\"border: 0px; font-family: inherit; font-size: 16px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px 0px 10px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;\"\u003E\n\u003Cdiv style=\"border: 0px; font-family: \u0026quot;Whitney SSm A\u0026quot;, \u0026quot;Whitney SSm B\u0026quot;, verdana, \u0026quot;Lucida Grande\u0026quot;, sans-serif; font-size: 18px; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;\"\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Cstrong style=\"border: 0px; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;\"\u003EProblem Statement\u003C\/strong\u003E\u003C\/h2\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv class=\"msB\" style=\"border: 0px; font-family: inherit; font-size: 16px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px 0px 10px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;\"\u003E\n\u003Cdiv style=\"background-color: white; border: 0px; color: #39424e; font-family: \u0026quot;Whitney SSm A\u0026quot;, \u0026quot;Whitney SSm B\u0026quot;, verdana, \u0026quot;Lucida Grande\u0026quot;, sans-serif; font-size: 18px; font-stretch: inherit; line-height: 1.5em; margin-bottom: 1em; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word; word-wrap: break-word;\"\u003E\nYou're given the pointer to the head node of a sorted linked list, where the data in the nodes is in ascending order. Delete as few nodes as possible so that the list does not contain any value more than once. The given head pointer may be null indicating that the list is empty.\u003C\/div\u003E\u003C\/div\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\nSource code:\u003C\/h2\u003E\n\u003Cpre style=\"background-image: URL(http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif); background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"\u003E\u003Ccode style=\"color: black; overflow-wrap: normal; word-wrap: normal;\"\u003E \/*  \n  Remove all duplicate elements from a sorted linked list  \n  Node is defined as   \n  struct Node  \n  {  \n    int data;  \n    struct Node *next;  \n  }  \n *\/  \n Node* RemoveDuplicates(Node *head)  \n {  \n  \/\/ This is a \"method-only\" submission.   \n  \/\/ You only need to complete this method.   \n   Node *cur = head;  \n   while(cur-\u0026gt;next!=NULL){  \n     if(cur-\u0026gt;data == cur-\u0026gt;next-\u0026gt;data)  \n       cur-\u0026gt;next = cur-\u0026gt;next-\u0026gt;next;   \n     else  \n     cur = cur-\u0026gt;next;  \n   }  \n   return head;  \n }  \n\u003C\/code\u003E\u003C\/pre\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/blog.grkweb.com\/feeds\/7563701694907052843\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-delete-duplicate-value-nodes.html#comment-form","title":"6 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/7563701694907052843"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/5735018943946871385\/posts\/default\/7563701694907052843"},{"rel":"alternate","type":"text/html","href":"https:\/\/blog.grkweb.com\/2015\/04\/hackerrank-delete-duplicate-value-nodes.html","title":"Delete duplicate value nodes from a sorted linked list Solution"}],"author":[{"name":{"$t":"GRK"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/00099219911209322075"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"6"}}]}});