1033. Moving Stones Until Consecutive ¶ Time: $O(\texttt{sort})$ Space: $O(\texttt{sort})$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12 13class Solution { public: vector<int> numMovesStones(int a, int b, int c) { vector<int> nums = {a, b, c}; ranges::sort(nums); if (nums[2] - nums[0] == 2) return {0, 0}; return {min(nums[1] - nums[0], nums[2] - nums[1]) <= 2 ? 1 : 2, nums[2] - nums[0] - 2}; } }; 1 2 3 4 5 6 7 8 9 10 11 12class Solution { public int[] numMovesStones(int a, int b, int c) { int[] nums = new int[] {a, b, c}; Arrays.sort(nums); if (nums[2] - nums[0] == 2) return new int[] {0, 0}; return new int[] {Math.min(nums[1] - nums[0], nums[2] - nums[1]) <= 2 ? 1 : 2, nums[2] - nums[0] - 2}; } } 1 2 3 4 5 6 7 8class Solution: def numMovesStones(self, a: int, b: int, c: int) -> list[int]: nums = sorted([a, b, c]) if nums[2] - nums[0] == 2: return [0, 0] return [1 if min(nums[1] - nums[0], nums[2] - nums[1]) <= 2 else 2, nums[2] - nums[0] - 2]