Every operation in O(1) using Two List in C++
\nclass FrontMiddleBackQueue {\npublic:\n    list<int> first,second;\n    FrontMiddleBackQueue() {\n        \n    }\n    \n    void pushFront(int val) {\n      
```\nclass FrontMiddleBackQueue {\npublic:\n    list<int> first,second;\n    FrontMiddleBackQueue() {\n        \n    }\n    \n    void pushFront(int val) {\n        \n        first.push_front(val);\n        // balence the logic\n        while(first.size()>second.size()+1){\n            second.push_front(first.back());\n            first.pop_back();\n        }\n    }\n    \n    void pushMiddle(int val) {\n        \n        if(first.size()>second.size()){\n            second.push_front(first.back());\n            first.pop_back();\n        }\n        \n        \n        first.push_back(val);\n\n        while(first.size()>second.size()+1){\n            second.push_front(first.back());\n            first.pop_back();\n        }\n    }\n    \n    void pushBack(int val) {\n        cout<<"pb"<<endl;\n        second.push_back(val);\n        \n        while(first.size()< second.size()){\n            first.push_back(second.front());\n            second.pop_front();\n        }\n    }\n    \n    int popFront() {\n        \n        \n        // Filling condition\n        if(first.size()==0){\n            return -1;\n        }\n\n        int ele = first.front();\n        first.pop_front();\n        while(first.size()< second.size()){\n            first.push_back(second.front());\n            second.pop_front();\n        }\n        \n        return ele;\n        \n    }\n    \n    int popMiddle() {\n        \n        if(first.size()==0){\n            return -1;\n        }\n\n        int ele = first.back();\n        \n        first.pop_back();\n        while(first.size()< second.size()){\n            first.push_back(second.front());\n            second.pop_front();\n        }\n        return ele;\n        \n    }\n    \n    int popBack() {\n        if(second.size()==0){\n            if(first.size()==0){\n                return -1;\n            }\n            \n            int ele = first.back();\n            first.pop_back();\n            \n            return ele;\n            \n        }\n\n        \n        // other condition\n        int ele =second.back();\n        second.pop_back();\n        // balence the logic\n        while(first.size()>second.size()+1){\n            second.push_front(first.back());\n            first.pop_back();\n        }\n        \n        return ele;\n        \n    }\n};\n```\nComplexity is O(1) , because for every insertion , deletion ,need to do 2-3 replacements,so overall it will never effect complexity.\n
['Linked List', 'C']