C++ easy solution using vector(may not work for high values of N)
Intuition\nWe just need to have a counter variable to know the size of our queue.It will be required when we add elements into middle or remove elements from th
# Intuition\nWe just need to have a counter variable to know the size of our queue.It will be required when we add elements into middle or remove elements from the middle, as we know the `erase()` function would delete according to the position provided by the user.\n\n# Approach\nWe simply initialize the counter and vector and applying thr above intuition, remove and add elements by decrementing and incrementing the counters respectively.\n\n# Complexity\n- Time complexity:\nFor `pushFront()`,`pushBack()`,`popFront()`,`popBack()` : - O(1).\nFor `pushMiddle` and `popMiddle()` :- O(N/2) \u2248 O(N).\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass FrontMiddleBackQueue {\npublic:\n    vector<int> v;\n    int cnt = 0;\n    FrontMiddleBackQueue() {\n        v.clear();\n\n    }\n    \n    void pushFront(int val) {\n        if(v.empty()) v.push_back(val);\n        else\n        v.insert(v.begin(),val);\n        cnt++;\n    }\n    \n    void pushMiddle(int val) {\n        v.insert(v.begin()+cnt/2,val);\n        cnt++;\n    }\n    \n    void pushBack(int val) {\n        v.push_back(val);\n        cnt++;\n    }\n    \n    int popFront() {\n        if(v.empty()) return -1;\n        int t = v[0];\n        v.erase(v.begin());\n        cnt--;\n        return t;\n    }\n    \n    int popMiddle() {\n        if(v.empty()) return -1;\n        int mid = cnt/2;\n        if(cnt % 2 == 0){\n         mid = v[cnt/2-1];\n        v.erase(v.begin()+cnt/2-1);\n        }\n        else{\n             mid = v[cnt/2];\n        v.erase(v.begin()+cnt/2);\n        }\n        cnt--;\n        return mid;\n    }\n    \n    int popBack() {\n        if(v.empty()) return -1;\n        int b = v[cnt-1];\n        v.pop_back();\n        cnt--;\n        return b;\n    }\n};\n\n/**\n * Your FrontMiddleBackQueue object will be instantiated and called as such:\n * FrontMiddleBackQueue* obj = new FrontMiddleBackQueue();\n * obj->pushFront(val);\n * obj->pushMiddle(val);\n * obj->pushBack(val);\n * int param_4 = obj->popFront();\n * int param_5 = obj->popMiddle();\n * int param_6 = obj->popBack();\n */\n```
['Array', 'Design', 'Data Stream', 'C++']