Get First And Get Last In Doubly Linkedlist
easy
1. You are given a partially written DoublyLinkedList class. 2. You are required to complete the body of size, isEmpty, getFirst and getLast function. This function is supposed to return size, empty state of linkedlist, first element and last element respectively. 3. If size of list is zero then return "ListIsEmpty: -1". 4. You are required to update head, tail and size as required. 5. Input and Output is managed for you. Just update the code in incomplete function. Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.
Constraints
0 <= N <= 10^6
Format
Input
input in managed for you.
Output
output in managed for you.
Example
Sample Input
addFirst 4
addFirst 4
addFirst 5
addFirst 7
addFirst 1
stop
Sample Output
[1, 7, 5, 4, 4]
Question Video