c++ solution
In my opinion, I think the problem is really not as easy as you think. \n\nclass Solution {\npublic:\n    vector<int> numMovesStonesII(vector<int>& stones) {\n 
In my opinion, I think the problem is really not as easy as you think. \n```\nclass Solution {\npublic:\n    vector<int> numMovesStonesII(vector<int>& stones) {\n        if(stones.empty()||stones.size()==1){\n            return {0,0};\n        }\n        if(stones.size() == 2){\n            return {0,0};\n        }\n        sort(stones.begin(),stones.end());\n        deque<int> window; \n        window.push_back(stones[0]);\n        int n = stones.size();\n        int count = 0;\n        int _min = INT_MAX; \n        int total = 0;\n        for(int i = 1;i<n;i++){\n            total += stones[i] - stones[i-1]-1;\n            int r = window[0] + n - 1; \n            if(stones[i]<=r){\n                count += stones[i] - window.back() - 1; \n                window.push_back(stones[i]);\n            } else {\n                if(window.back() == r) {\n                     _min = min(_min,count);\n                }\n                else if(window.size() + 1 != n) {\n                    _min = min(_min,count + r - window.back());\n                }\n                int front = window.front();\n                window.pop_front();\n                if(window.size()){\n                    total -= stones[i] - stones[i-1] -1;\n                    count -= window.front() - front - 1; \n                    i--;\n                } else {\n                    count = 0; \n                    window.push_back(stones[i]);\n                }\n               \n            }\n        }\n        int l = window.back() - n + 1; \n        if(window.front() == l){\n            _min = min(_min,count);\n        } else if(window.size() + 1 != n){\n            _min = min(_min,count + window.front() - l);\n        }\n        int x = min(stones[1] - stones[0] - 1, stones[stones.size()-1] - stones[stones.size()-2] - 1);\n        int _max = total - x;\n        return {_min,_max};\n    }\n};\nconst int _ = [](){\n    ios_base::sync_with_stdio(false);\n    cin.tie(NULL);\n    cout.tie(NULL);\n    return 0;\n}();\n```
[]