"""
1509
medium
Minimum Difference Between Largest and Smallest Value in Three Moves
"""

from typing import List


class Solution:
    def minDifference(self, nums: List[int]) -> int:

        if len(nums) <= 4:
            return 0

        nums.sort()

        return min(nums[-1] - nums[3], nums[-2] - nums[2], nums[-3] - nums[1], nums[-4] - nums[0])

nums = [5,3,2,4]
nums = [1,5,0,10,14]
nums = [6,6,0,1,1,4,6]
sol = Solution()
print(sol.minDifference(nums))
"""
1509
medium
Minimum Difference Between Largest and Smallest Value in Three Moves
"""

from typing import List


class Solution:
    def minDifference(self, nums: List[int]) -> int:

        if len(nums) <= 4:
            return 0

        nums.sort()

        return min(nums[-1] - nums[3], nums[-2] - nums[2], nums[-3] - nums[1], nums[-4] - nums[0])

nums = [5,3,2,4]
nums = [1,5,0,10,14]
nums = [6,6,0,1,1,4,6]
sol = Solution()
print(sol.minDifference(nums))
1509 medium Minimum Difference Between Largest and Smallest Value in Three Moves