Leetcode 1616 Solution

This article provides solution to leetcode question 1616 (minimum-difference-between-largest-and-smallest-value-in-three-moves)

https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves

Solution

class Solution:
    def minDifference(self, nums: List[int]) -> int:
        if len(nums) <= 4:
            return 0

        nums.sort()

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