Python O(1) time and space
Intuition\n Describe your first thoughts on how to solve this problem. \nThis is a game that can easily be thought of playing in real life, I did not consider t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis is a game that can easily be thought of playing in real life, I did not consider the game as a technical leetcode problem but approached it as if the rocks were in front of me.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nMax moves is easier to calculate. Since one of the endpoints must be moved inwards, at the very least 1 empty space is consumed. Then, the slowest approach to reach the max moves is to move the endpoints as little as possible (1 space). The max moves is then equal to the number of space between the endpoints which is right-left-2, assuming right is the right most rock and left is the left most.\n\nMin moves is more interesting, it wants to eliminate as much space as possible. If there is no space between the rocks (between left and mid or between mid and right), then the min moves is 0. If there is space on one side of mid but not the other, then eliminate that space by moving the endpoint inwards. Ex: rocks are [1, 2, 5]. There is no space on the left, but there is space between 2 and 5. Eliminate by moving 5 to 3. Only 1 move needed.\n\nIf there is space on the left and right of mid, then 2 moves are needed (yes there is a caveat, explained later below). Imagine the rocks are [1, 4, 9]. First eliminate the left space by moving 1 to 3. Then eliminate the right space by moving 9 to 5. No more moves needed, so the maximum value of min moves can ever be is 2. The idea is that a "group" of space can be eliminated in only one move, here there are 2 space groups.\n\nCaveat: imagine the rocks are [1, 5, 7]. There are 2 spaces, so 2 moves... needed right? Actually, only 1 move needed because one of the spaces is only of size 1 (from 5 to 7, only 6 empty). We can eliminate the left space (by moving 1 inwards) and the singular right space in 1 fell swoop: move 1 to that space! Rocks take 1 space themselves which makes this instance pretty cool.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(1), no loops of any kind\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1), no list or similar structure\n# Code\n```\nclass Solution:\n    def numMovesStones(self, a: int, b: int, c: int) -> List[int]:\n        left = min(a, b)\n        left = min(left, c)\n\n        right = max(a, b)\n        right = max(right, c)\n\n        mid = None\n\n        if a!= left and a!= right:\n            mid = a\n        elif b != left and b!= right:\n            mid = b\n        else:\n            mid = c\n\n\n        space_a_b = mid-left-1\n        space_b_c = right-mid-1\n        \n        if space_a_b == 0 and space_b_c == 0:\n            return [0, right-left-2]\n        elif space_a_b == 0 or space_b_c == 0:\n            return [1, right-left-2]\n        elif space_a_b == 1 or space_b_c == 1:\n            return [1, right-left-2]\n        else:\n            return [2, right-left-2]\n\n```
['Python3']