Display A Linkedlist

easy
1. You are given a partially written LinkedList class.
2. Here is a list of existing functions:
   2.1 addLast - adds a new element with given value to the end of Linked List
3. You are required to complete the body of display function and size function
   3.1. display - Should print the elements of linked list from front to end in a single line. Elements should be separated by space.
   3.2. size - Should return the number of elements in the linked list.
4. Input and Output is managed for you.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

None

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
addLast 10
addLast 20
addLast 30
display
size
addLast 40
addLast 50
display
size
quit
Output
10 20 30 
3
10 20 30 40 50 
5
Previous
Add Last In Linked List
Next
Remove First In Linkedlist

Related Questions