💯EASIEST || C++ || SLIDING WINDOW
\n\nDo upvote if you like it!\n\n\nclass Solution {\npublic:\n    vector<int> numMovesStonesII(vector<int>& stones) {\n        sort(begin(stones), end(stones));
\n\n**Do upvote if you like it!**\n\n```\nclass Solution {\npublic:\n    vector<int> numMovesStonesII(vector<int>& stones) {\n        sort(begin(stones), end(stones)); \n        int n = size(stones), ii = 0, low = INT_MAX; \n        int high = max(stones[n-2] - stones[0], stones[n-1] - stones[1]) - (n - 2); \n        \n        for (int i = 0; i < n; ++i) {\n            while (stones[i] - stones[ii] >= n) ++ii; \n            if (i - ii + 1 == n - 1 && stones[i] - stones[ii] == n - 2) \n                low = min(low, 2); \n            else low = min(low, n - (i - ii + 1)); \n        }\n        return {low, high}; \n    }\n};\n```\n\n![image](https://assets.leetcode.com/users/images/50716ce6-13ea-426b-8970-f53a676b0260_1662902067.4393857.jpeg)\n
['C++']