Add Last In Linked List

easy
 1. You are given a partially written LinkedList class.
2. You are required to complete the body of addLast function. This function is supposed to add an element to the end of LinkedList. You are required to update head, tail and size as required.
3. Input and Output is managed for you. Just update the code in addLast function.                  

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
addLast 40
addLast 50
quit
Output
10
20
30
40
50
5
50
Next
Display A Linkedlist

Related Questions