Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Print Linked List elements
Basic Accuracy: 47.38% Submissions: 51775 Points: 1

You are given the pointer to the head node of a linked list. You have to print all of its elements in order in a single line.

You have to complete a method which takes one argument: the head of the linked list. You should not read any input from stdin/console. The struct Node has a data part which stores the data and a next pointer which points to the next element of the linked list. There are multiple test cases. For each test case, this method will be called individually.

Print the elements of the linked list in a single line separated by a single space.

Your Task:

You don't need to read input or print anything. Your task is to complete the function display() which takes the head (the head node of the linked list) and You have to print the elements of the linked list.


LinkedList={1 , 2}
1 2
Here the first line denotes an integer 'N' the no of nodes 
of linked list .Then the line after that contains N space
separated integers denoting the values of the nodes of
the linked list.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Print Linked List elements

Output Window