Not so fast but easily understandable || C++ || Queues
Added full code with comments, lemme know in case of any doubts. Please don\'t forget to UPVOTE.\n\n\nclass FrontMiddleBackQueue {\npublic:\n\n    queue<int> q;
Added full code with comments, lemme know in case of any doubts. Please don\'t forget to UPVOTE.\n\n```\nclass FrontMiddleBackQueue {\npublic:\n\n    queue<int> q;\n    FrontMiddleBackQueue() {\n        \n    }\n    \n    void pushFront(int val) {\n        // push function pushes val at end of the queue\n        \n        // take out all elements of queue and add in vector, v\n        vector<int> v;\n        while (q.size()>0){\n            v.push_back(q.front());\n            q.pop();\n        }\n        \n        // now since queue.size()==0, push the val to add it at front\n        q.push(val);\n        \n        // now add the elements from v to queue.\n        int n = v.size();\n        int i=0;\n        while (i<n){\n            q.push(v[i]);\n            i++;\n        }\n        \n    }\n    \n    void pushMiddle(int val) {\n        // push function pushes val at end of the queue\n        \n        // take out all elements of queue and add in vector, v\n        vector<int> v;\n        while (q.size()>0){\n            v.push_back(q.front());\n            q.pop();\n        }\n        \n        // middle index, see idx = floor(v.size()/2) == (int)(v.size()/2) (in C++)\n        int idx = v.size()/2;\n        \n        // now insert val at middle position, idx\n        v.insert(v.begin()+idx,val);\n        \n        // now push all elements from v to queue.\n        int n = v.size();\n        int i=0;\n        while (i<n){\n            q.push(v[i]);\n            i++;\n        }\n        \n    }\n    \n    void pushBack(int val) {\n        // push function pushes val at end of the queue, which is what we want here\n        q.push(val);\n    }\n    \n    int popFront() {\n        // if no element in queue, nothing to pop\n        if (q.size()<=0) return -1;\n        \n        // pop function removes element from front.\n        // front function returns element from front, which is required here.\n        int ans = q.front();\n        q.pop();\n        \n        return ans;\n    }\n    \n    int popMiddle() {\n        // if no element in queue, nothing to pop\n        if (q.size()<=0) return -1;\n        \n        // get all elements from queue to v.\n        vector<int> v;\n        while (q.size()>0){\n            v.push_back(q.front());\n            q.pop();\n        }\n        \n        // find deletion index\n        int idx = (v.size())/2;\n        \n        // notice from [1, 2, 3, 4, 5, 6] the element to pop is 3, idx=2, i.e. (size/2)-1\n        if (v.size()%2==0 && idx>0) idx--; // in case of even size only.\n        \n        // finding value at that index\n        int ans = v[idx];\n        \n        // erase the element at idx\n        v.erase(v.begin()+idx);\n        \n        // push remaining elements to queue\n        int n = v.size();\n        int i=0;\n        while (i<n){\n            q.push(v[i]);\n            i++;\n        }\n        \n        return ans;\n    }\n    \n    int popBack() {\n        // if q.size()<=0 nothing to pop.\n        if (q.size()<=0) return -1;\n        \n        // add elements of queue to v.\n        vector<int> v;\n        while (q.size()>0){\n            v.push_back(q.front());\n            q.pop();\n        }\n        \n        // when popping back, we need to remove last element of v, idx = (v.size()-1)\n        int ans = v[v.size()-1];\n        \n        // remove that element\n        v.pop_back();\n        \n        // adding remaining elements\n        int n = v.size();\n        int i=0;\n        while (i<n){\n            q.push(v[i]);\n            i++;\n        }\n        return ans;\n    }\n};\n```
['Queue', 'C']