Print the elements of a linked list in reverse
The following is the solution to Hacker Rank problem Print the elements of a linked list in reverse using Java. For solutions to other Hacker Rank Problem visit my page HackerRank, alternatively try searching for the problem in my blog.
Score: 5/5
void ReversePrint(Node *head)
{
if(head == NULL)
return;
// traverse the list
ReversePrint(head->next);
//print the element
printf("%d\n",
head->data);
}
The following is the solution to Hacker Rank problem Print the elements of a linked list in reverse using Java. For solutions to other Hacker Rank Problem visit my page HackerRank, alternatively try searching for the problem in my blog.
void ReversePrint(Node *head)
{
if(head == NULL)
return;
// traverse the list
ReversePrint(head->next);
//print the element
printf("%d\n",
head->data);
}
|
No comments:
Post a Comment