Python Solution 🚀
Intuition\nThe problem requires minimizing the difference between the largest and smallest values in an array after at most three moves. By changing up to three
### Intuition\nThe problem requires minimizing the difference between the largest and smallest values in an array after at most three moves. By changing up to three elements to any value, we can effectively remove up to three outliers. Thus, the core insight is that we can minimize the range by focusing on changing either the smallest or the largest elements.\n\n### Approach\n1. **Sort the Array:** Sorting helps us quickly access the smallest and largest elements in a structured manner.\n2. **Consider Edge Case:** If the array has 4 or fewer elements, we can make all elements the same with three moves, resulting in a difference of 0.\n3. **Analyze Scenarios:** Post sorting, consider four scenarios:\n    - Change the three smallest elements to the fourth smallest element.\n    - Change the two smallest elements and the largest element.\n    - Change the smallest element and the two largest elements.\n    - Change the three largest elements to the fourth largest element.\n4. **Compute Differences:** Calculate the differences for these scenarios.\n5. **Return Minimum Difference:** The result is the minimum difference computed from the above scenarios.\n\n### Complexity\n- **Time complexity:** \\(O(n \\log n)\\) due to sorting the array.\n- **Space complexity:** \\(O(1)\\) as we are using a constant amount of extra space for computation, aside from the input array.\n\n# Code\n```\nclass Solution:\n    def minDifference(self, nums: List[int]) -> int:\n        if len(nums) <= 4:\n            return 0\n        \n        nums.sort()\n        \n        # Possible scenarios to consider after sorting\n        return min(\n            nums[-1] - nums[3],    # Remove the three smallest\n            nums[-2] - nums[2],    # Remove the two smallest and the largest\n            nums[-3] - nums[1],    # Remove the smallest and the two largest\n            nums[-4] - nums[0]     # Remove the three largest\n        )\n\n```
['Python3']