Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created May 9, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/91e8dfeac0e962307b30f4afd0bb6f98 to your computer and use it in GitHub Desktop.
Save jianminchen/91e8dfeac0e962307b30f4afd0bb6f98 to your computer and use it in GitHub Desktop.
HackerRank - Linked List - reverse print
/*
Print elements of a linked list in reverse order as standard output
head pointer could be NULL as well for empty list
Node is defined as
struct Node
{
int data;
struct Node *next;
}
*/
void ReversePrint(Node *head)
{
if(head==NULL)
return;
if(head->next==NULL)
{
printf("%d\n", head->data);
return;
}
ReversePrint(head->next);
printf("%d\n", head->data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment