Remove At In Doubly Linkedlist

medium
1. You are given a partially written DoublyLinkedList class.
2. You are required to complete the body of RemoveAt function. This function is supposed to Remove value at given index and return in back. 
3. If size of list is zero then return "ListIsEmpty: -1".
4. If Index is Invalid then return "IndexIsInValid: -1". 
5. You are required to update head, tail and size as required.
6. 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.

Input Format

input in managed for you.

Output Format

output in managed for you.

Constraints

0 <= N <= 10^6

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
addFirst 4
addFirst 4
addLast 5
addFirst 7
getAt 4 3
addAt 4 34
addAt 0 43
removeAt 4
removeAt 0
addAt 8 545
addLast 1
removeFirst
removeFirst
size
isEmpty
getFirst
removeFirst
removeLast
getLast
removeFirst
removeFirst
addAt 0 345
stop
Output
IndexIsInValid: -1
IndexIsInValid: -1
7
4
3
false
4
4
1
34
34
ListIsEmpty: -1
[345]
Previous
Add At In Doubly Linkedlist
Next
Add Before In Doubly Linkedlist

Related Questions