Easy C++ solution doubly linked list
\n// definition of doubly linked list\nclass node {\n    public:\n    int data;\n    node *next,*prev;\n};\n\n// function to get a new node\nnode *getNode(int d
```\n// definition of doubly linked list\nclass node {\n    public:\n    int data;\n    node *next,*prev;\n};\n\n// function to get a new node\nnode *getNode(int d) {\n    node *newNode=new node;\n    newNode->data=d;\n    newNode->prev=newNode->next=NULL;\n    return newNode;\n}\nclass FrontMiddleBackQueue {\npublic:\n    // \'head\' is the head of the doubly linked list\n    // \'last\' is the last node of the doubly linked list\n\n    node *head=NULL,*last=NULL;\n    FrontMiddleBackQueue() {\n        head=last=NULL;\n    }\n    \n    // typical logic of inserting a node at the front of a doubly linked list\n    void pushFront(int val) {\n        node *newNode=getNode(val);\n        if(!head) {\n            head=last=newNode;\n        }\n        else {\n            newNode->next=head;\n            head->prev=newNode;\n            head=newNode;\n        }\n    }\n    \n    void pushMiddle(int val) {\n        // if there are fewer than one node then pushing into the middle is same as pushing at the front\n        if(!head || !head->next) {\n            pushFront(val);\n            return;\n        }\n        \n        // apply "Here and tortoise technique" to get into the middle of linked list and also maintain a \'past\' pointer which will point to the previous node of \'slow\' pointer\n        node *slow=head,*fast=head,*past=head;\n        while(fast && fast->next) {\n            past=slow;\n            slow=slow->next;\n            fast=fast->next->next;\n        }\n        // at the end \'slow\' will point to the middle\n        // at the end \'past\' will point to previous of middle \n        // insert the node between \'past\' and \'slow\' pointer node\n        node *newNode=getNode(val);\n        past->next=newNode;\n        newNode->prev=past;\n        newNode->next=slow;\n        slow->prev=newNode;\n    }\n    // typical logic of inserting a node at the last of a doubly linked list\n    void pushBack(int val) {\n        node *newNode=getNode(val);\n        if(!head) {\n            head=last=newNode;\n        }\n        else {\n            last->next=newNode;\n            newNode->prev=last;\n            last=newNode;\n        }\n    }\n    \n    int popFront() {\n        if(!head) {\n            return -1;\n        }\n        int d=head->data;\n        if(!head->next) {\n            head=last=NULL;\n            return d;\n        }\n        else {\n            head=head->next;\n            head->prev=NULL;\n        }\n        return d;\n    }\n    int popMiddle() {\n        // if there are no node then return -1 as its empty\n        if(!head) {\n            return -1;\n        }\n        \n        // if there are less than or equal to 2 node then remove the first node\n        else if(!head->next || !head->next->next) {\n            return popFront();\n        }\n        // apply "Here and tortoise technique" to get into the middle of linked list and also maintain a \'past\' pointer which will point to the previous node of \'slow\' pointer\n        node *slow=head,*fast=head,*past=head;\n        while(fast && fast->next) {\n            past=slow;\n            slow=slow->next;\n            fast=fast->next->next;\n        }\n        \n        // if there are even number of nodes the popped value will be the previous node value of middle as it is the first middle position\n        // if there are odd number of nodes the popped value will be  middle node value \n        int d=fast?slow->data:past->data;\n        \n        // if there are even number of nodes then \'fast\' will be NULL\n        if(!fast) {\n            // remove the \'past\' pointer node\n            node *tmp=past->prev;\n            tmp->next=slow;\n            slow->prev=tmp;\n        }\n        \n        // if there are odd number of nodes then fast will not be NULL\n        else {\n            // remove the \'slow\' pointer node as it\'s the middle\n            node *tmp=slow->next;\n            past->next=tmp;\n            tmp->prev=past;\n        }\n        return d;\n    }\n    \n    int popBack() {\n        if(!last) {\n            return -1;\n        }\n        int d=last->data;\n        if(!head->next) {\n            head=last=NULL;\n        }\n        else {\n            last=last->prev;\n            last->next=NULL;\n        }\n        return d;\n    }\n};\n```\n***Please upvote if you have got any help from my code. Thank you.***
['C', 'Doubly-Linked List']