2740. Find the Value of the Partition
You are given a positive integer array
nums
.Partition
nums
into two arrays,nums1
andnums2
, such that:
- Each element of the array
nums
belongs to either the arraynums1
or the arraynums2
.- Both arrays are non-empty.
- The value of the partition is minimized.
The value of the partition is
|max(nums1) - min(nums2)|
.Here,
max(nums1)
denotes the maximum element of the arraynums1
, andmin(nums2)
denotes the minimum element of the arraynums2
.Return the integer denoting the value of such partition.
1 | class Solution { |