Python 3   ||   8 lines, sliding window w/ bin search    ||   T/S: 66% / 57%
Pretty much what everyone else has, but for what it\'s worth, it does use a bin search to locate the windows.\n\nclass Solution:\n    def numMovesStonesII(self,
Pretty much what everyone else has, but for what it\'s worth, it does use a bin search to locate the windows.\n```\nclass Solution:\n    def numMovesStonesII(self, stones: List[int]) -> List[int]:\n        \n        stones.sort()\n        n, lo = len(stones), inf\n\n        for right in range(n):\n\n            left= bisect_right(stones,stones[right]-n)\n\n            if right-left == stones[right]-stones[left] == n-2: lo = min(lo, 2)\n            \n            else: lo = min(lo, n - (right-left+1))\n\n        hi = max(stones[n-1]-stones[1], stones[n-2]-stones[0]) - n + 2    \n\n        return [lo, hi]\n\n```\n[https://leetcode.com/problems/moving-stones-until-consecutive-ii/submissions/1273657024/](https://leetcode.com/problems/moving-stones-until-consecutive-ii/submissions/1273657024/)\n\nI could be wrong, but I think that time complexity is *O*(*N* log *N*) and space complexity is *O*(1), in which *N* ~ `len(stones)`.\n
['Python']