Easy C++ solution using deque
\nclass Solution {\npublic:\n    int ans=INT_MAX;\n    void solve(deque<int> &dq,int cnt)\n    {\n        if(cnt==3)\n        {\n            ans=min(ans,dq.back
```\nclass Solution {\npublic:\n    int ans=INT_MAX;\n    void solve(deque<int> &dq,int cnt)\n    {\n        if(cnt==3)\n        {\n            ans=min(ans,dq.back()-dq.front());\n            return;\n        }\n        int temp=dq.front();\n        dq.pop_front();\n        solve(dq,cnt+1);\n        dq.push_front(temp);\n        temp=dq.back();\n        dq.pop_back();\n        solve(dq,cnt+1);\n        dq.push_back(temp);\n    }\n    int minDifference(vector<int>& nums) {\n        deque<int> dq;\n        if(nums.size()<=4) return 0;\n        sort(nums.begin(),nums.end());\n        for(auto &x:nums) dq.push_back(x);\n        solve(dq,0);\n        return ans;\n    }\n};\n```
['Queue']