💠 Ruby one-liner solution
Intuition\n\nIf the length of the array is $4$ or less, we could easily see that the answer is $0$, because we have enough operations to turn all elements of th
# Intuition\n\nIf the length of the array is $4$ or less, we could easily see that the answer is $0$, because we have enough operations to turn all elements of the array to the same number.\n\nOtherwise, we can see that to achieve the best answer, we would have to remove some largest, or some smallest numbers, or both, from the array.\n\n# Approach\n\nLet\'s set $nums\' = sort(nums)$, the answer will be one of four:\n\n- $nums\'[n - 4] - num\'[0]$.\n- $nums\'[n - 3] - num\'[1]$.\n- $nums\'[n - 2] - num\'[2]$.\n- $nums\'[n - 1] - num\'[3]$.\n\nTherefore, we will try some way to create the enumerator with these 4 elements and use `min` function on it.\n\nWe will also use `sort!` to modify `nums`, instead of `sort` which would just return the sorted array without any modification. Note that this is not a good practice at all, but it would help solving the one-liner challenge.\n\n# Complexity\n- Time complexity: $O(n * log(n))$\n\n- Space complexity: $O(1)$\n\n# Code\n```\n# @param {Integer[]} nums\n# @return {Integer}\ndef min_difference(nums)\n    nums.sort!.length <= 4 ? 0 : 4.times.map { |i| nums[i - 4] - nums[i] }.min\nend\n```
['Ruby']