You are viewing a single comment's thread. Return to all comments →
here's my solution in C language
void reversePrint(SinglyLinkedListNode* llist) { SinglyLinkedListNode *pre = NULL; SinglyLinkedListNode *next = NULL; SinglyLinkedListNode *current = llist;
while(current != NULL){ next = current -> next; current -> next = pre; pre = current; current = next; } llist = pre; while(llist != NULL){ printf("%d\n", llist->data); llist = llist->next; }
}
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
here's my solution in C language
void reversePrint(SinglyLinkedListNode* llist) { SinglyLinkedListNode *pre = NULL; SinglyLinkedListNode *next = NULL; SinglyLinkedListNode *current = llist;
}