A concise solution
If there are 4 or less elements in it, we\'re going to be left with 1 element at most, making the difference b/w min and max 0.\nIf there are more elements, the
If there are 4 or less elements in it, we\'re going to be left with 1 element at most, making the difference b/w min and max 0.\nIf there are more elements, then we have one of these four choices:\n1. get rid of the 3 biggest elements.\n2. get rid of 2 biggest elements, and the smallest.\n3. get rid of the biggest element, and 2 smallest.\n4. get rid of the 3 smallest elements.\n\nAnd in these four choices respectively, the min and the max will be the following:\n1. 1st element, and 4th from the last\n2. 2nd element, and 3rd from the last\n3. 3rd element, and 2nd from the last\n4. 4th element, and (1st from) the last.\n\nIn other words, we simply need to take the pairwise difference b/w the 4 smallest elements in the array, and the 4 largest elements in the array (in reverse order). Sorting the entire array for this is inefficient. A more efficient way is provided by the `heapq` module.\n\nAnd of course, we can use this for any number of moves, not just 3. At a large number of moves though, it would be faster to sort the entire array.\n```python\nimport heapq\n\nclass Solution:\n    def minDifference(self, nums: List[int]) -> int:\n        return 0 if len(nums) <= 4 else min(y-x for x, y in zip(heapq.nsmallest(4, nums), reversed(heapq.nlargest(4, nums))))\n```
['Heap (Priority Queue)', 'Python']