This commit is contained in:
parent
9ebf9885c3
commit
0f7c398b5e
1 changed files with 16 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
||||||
|
# https://leetcode.com/problems/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],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue