Leetcode 1616 Solution
This article provides solution to leetcode question 1616 (minimum-difference-between-largest-and-smallest-value-in-three-moves)
Access this page by simply typing in "lcs 1616" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
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],
)