Java | ArrayDeque | Easy Solution
\nclass FrontMiddleBackQueue {\n     ArrayDeque<Integer> q;\n    public FrontMiddleBackQueue() {\n        q=new ArrayDeque<>();\n    }\n    \n    public void pu
```\nclass FrontMiddleBackQueue {\n     ArrayDeque<Integer> q;\n    public FrontMiddleBackQueue() {\n        q=new ArrayDeque<>();\n    }\n    \n    public void pushFront(int val) {\n        q.addFirst(val);\n    }\n    \n    public void pushMiddle(int val) {\n     int size=q.size();\n      if(size==0){\n        q.add(val);\n      }\n      else{\n        ArrayDeque<Integer> temp=new ArrayDeque<>();\n        int pos=0;\n        int mid=size/2;\n        while(pos<mid){\n          temp.addLast(q.removeFirst());\n          pos++;\n        }\n        temp.add(val);\n        while(temp.size()>0){\n          q.addFirst(temp.removeLast());\n        }\n      \n      }\n    }\n    \n    public void pushBack(int val) {\n        q.addLast(val);\n    }\n    \n    public int popFront() {\n      if(q.size()==0) return -1;\n       return q.removeFirst();\n    }\n    \n    public int popMiddle() {\n      if(q.size()==0) return -1;\n      int mid;\n      int size=q.size();\n      if(size%2==0){\n        mid=q.size()/2-1;\n      }\n      else{\n        mid=q.size()/2;\n      }\n      \n      ArrayDeque<Integer> temp=new ArrayDeque<>();\n      int pos=0;\n      while(pos<mid){\n        temp.addLast(q.removeFirst());\n        pos++;\n      }\n      int val=q.removeFirst();\n      while(temp.size()>0){\n        q.addFirst(temp.removeLast());\n      }\n      return val;\n    }\n    \n    public int popBack() {\n      if(q.size()==0) return -1;\n      return q.removeLast();\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```
[]