Java ArrayList solution || Runtime 7ms
Intuition\nMake ArrayList to function as front back middle q\n\n# Approach\nApply q functions to ArrayList as per given rules \n\n# Complexity\n- Time complexit
# Intuition\nMake ArrayList to function as front back middle q\n\n# Approach\nApply q functions to ArrayList as per given rules \n\n# Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(n) - size of array - no of elements in array\n\n# Code\n```\nclass FrontMiddleBackQueue {\n\n    List<Integer> qList;\n\n    public FrontMiddleBackQueue() {\n        qList = new ArrayList<>();\n    }\n\n    public void pushFront(int val) {\n        qList.add(0, val);\n    }\n\n    public void pushMiddle(int val) {\n        int mid = qList.size()/2;\n        qList.add(mid, val);\n    }\n\n    public void pushBack(int val) {\n        qList.add(qList.size(), val);\n    }\n\n    public int popFront() {\n        return qList.isEmpty()? -1 : qList.remove(0);\n    }\n\n    public int popMiddle() {\n        return qList.isEmpty()? -1 : qList.remove((qList.size()-1)/2);\n    }\n\n    public int popBack() {\n        return qList.isEmpty()? -1 : qList.remove(qList.size()-1);\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', 'Java']